diff --git a/src/app/app_brushes.cpp b/src/app/app_brushes.cpp index f1dbe96b2..fd70a186f 100644 --- a/src/app/app_brushes.cpp +++ b/src/app/app_brushes.cpp @@ -179,20 +179,31 @@ AppBrushes::AppBrushes() m_standard.push_back(BrushRef(new Brush(kSquareBrushType, 7, 0))); m_standard.push_back(BrushRef(new Brush(kLineBrushType, 7, 44))); - try { - std::string fn = m_userBrushesFilename = userBrushesFilename(); - if (base::is_file(fn)) + std::string fn = userBrushesFilename(); + if (base::is_file(fn)) { + try { load(fn); + } + catch (const std::exception& ex) { + LOG(ERROR, "BRSH: Error loading user brushes from '%s': %s\n", + fn.c_str(), ex.what()); + } } - catch (const std::exception& ex) { - LOG(ERROR, "BRSH: Error loading user brushes: %s\n", ex.what()); - } + m_userBrushesFilename = fn; } AppBrushes::~AppBrushes() { - if (!m_userBrushesFilename.empty()) - save(m_userBrushesFilename); + if (!m_userBrushesFilename.empty()) { + try { + save(m_userBrushesFilename); + } + // We cannot throw exceptions from a destructor + catch (const std::exception& ex) { + LOG(ERROR, "BRSH: Error saving user brushes to '%s': %s\n", + m_userBrushesFilename.c_str(), ex.what()); + } + } } AppBrushes::slot_id AppBrushes::addBrushSlot(const BrushSlot& brush) diff --git a/src/app/xml_document.cpp b/src/app/xml_document.cpp index 7628bc675..35bd5cd72 100644 --- a/src/app/xml_document.cpp +++ b/src/app/xml_document.cpp @@ -38,8 +38,10 @@ XmlDocumentRef open_xml(const std::string& filename) void save_xml(XmlDocumentRef doc, const std::string& filename) { FileHandle file(open_file(filename, "wb")); - if (!file) + if (!file) { + // TODO add information about why the file couldn't be opened (errno?, win32?) throw Exception("Error loading file: " + filename); + } if (!doc->SaveFile(file.get())) throw XmlException(doc.get());