Hand apply 5e96dbee6de3b4baf82083e5c7169f27e6051c5b from master; give a nicer error...
authorCarl Hetherington <cth@carlh.net>
Tue, 9 Dec 2014 11:00:22 +0000 (11:00 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 9 Dec 2014 11:00:22 +0000 (11:00 +0000)
src/lib/config.cc
src/tools/dcpomatic.cc

index a15825dc7e0f56fb3b511afe37d43d8d1ca3e0e8..c571376f0f35536c062652a662cdc47bf86295c8 100644 (file)
@@ -52,8 +52,7 @@ using std::exception;
 using std::cerr;
 using boost::shared_ptr;
 using boost::optional;
-using boost::algorithm::is_any_of;
-using boost::algorithm::split;
+using boost::algorithm::trim;
 using dcp::raw_convert;
 
 Config* Config::_instance = 0;
@@ -379,8 +378,14 @@ Config::write () const
        for (vector<boost::filesystem::path>::const_iterator i = _history.begin(); i != _history.end(); ++i) {
                root->add_child("History")->add_child_text (i->string ());
        }
-       
-       doc.write_to_file_formatted (file().string ());
+
+       try {
+               doc.write_to_file_formatted (file().string ());
+       } catch (xmlpp::exception& e) {
+               string s = e.what ();
+               trim (s);
+               throw FileError (s, file ());
+       }
 }
 
 boost::filesystem::path
index 0c82898aa83999adf02cc2bee9ef3de8fececaca..27f029d9be44c9c3f6e6a0661849509797e85689 100644 (file)
@@ -839,8 +839,11 @@ class App : public wxApp
        {
                try {
                        throw;
+               } catch (FileError& e) {
+                       error_dialog (0, wxString::Format (_("An exception occurred: %s in %s.\n\n" + REPORT_PROBLEM), e.what(), e.file().string().c_str ()));
                } catch (exception& e) {
-                       error_dialog (0, wxString::Format (_("An exception occurred (%s)."), e.what ()) + "  " + REPORT_PROBLEM);               } catch (...) {
+                       error_dialog (0, wxString::Format (_("An exception occurred: %s.\n\n"), e.what ()) + "  " + REPORT_PROBLEM);
+               } catch (...) {
                        error_dialog (0, _("An unknown exception occurred.") + "  " + REPORT_PROBLEM);
                }