Catch exceptions by const reference

This commit is contained in:
Robin Gareus 2017-11-23 10:38:52 +01:00
parent 3009fd7574
commit 12a5102713
3 changed files with 9 additions and 9 deletions

View file

@ -1969,7 +1969,7 @@ ARDOUR_UI::open_session ()
string default_session_folder = Config->get_default_session_parent_dir(); string default_session_folder = Config->get_default_session_parent_dir();
open_session_selector.add_shortcut_folder (default_session_folder); open_session_selector.add_shortcut_folder (default_session_folder);
} }
catch (Glib::Error & e) { catch (Glib::Error const& e) {
std::cerr << "open_session_selector.add_shortcut_folder() threw Glib::Error " << e.what() << std::endl; std::cerr << "open_session_selector.add_shortcut_folder() threw Glib::Error " << e.what() << std::endl;
} }
@ -3642,7 +3642,7 @@ ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name,
/* this one is special */ /* this one is special */
catch (AudioEngine::PortRegistrationFailure& err) { catch (AudioEngine::PortRegistrationFailure const& err) {
MessageDialog msg (err.what(), MessageDialog msg (err.what(),
true, true,
@ -3667,7 +3667,7 @@ ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name,
} }
goto out; goto out;
} }
catch (SessionException e) { catch (SessionException const& e) {
MessageDialog msg (string_compose( MessageDialog msg (string_compose(
_("Session \"%1 (snapshot %2)\" did not load successfully:\n%3"), _("Session \"%1 (snapshot %2)\" did not load successfully:\n%3"),
path, snap_name, e.what()), path, snap_name, e.what()),
@ -3803,7 +3803,7 @@ ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name,
new_session = new Session (*AudioEngine::instance(), path, snap_name, bus_profile); new_session = new Session (*AudioEngine::instance(), path, snap_name, bus_profile);
} }
catch (SessionException e) { catch (SessionException const& e) {
cerr << "Here are the errors associated with this failed session:\n"; cerr << "Here are the errors associated with this failed session:\n";
dump_errors (cerr); dump_errors (cerr);
cerr << "---------\n"; cerr << "---------\n";

View file

@ -1323,7 +1323,7 @@ LuaInstance::interactive_add (LuaScriptInfo::ScriptType type, int id)
try { try {
script = Glib::file_get_contents (spi->path); script = Glib::file_get_contents (spi->path);
} catch (Glib::FileError e) { } catch (Glib::FileError const& e) {
string msg = string_compose (_("Cannot read script '%1': %2"), spi->path, e.what()); string msg = string_compose (_("Cannot read script '%1': %2"), spi->path, e.what());
Gtk::MessageDialog am (msg); Gtk::MessageDialog am (msg);
am.run (); am.run ();
@ -1360,7 +1360,7 @@ LuaInstance::interactive_add (LuaScriptInfo::ScriptType type, int id)
string msg = string_compose (_("Session script '%1' instantiation failed: %2"), spd.name(), e.what ()); string msg = string_compose (_("Session script '%1' instantiation failed: %2"), spd.name(), e.what ());
Gtk::MessageDialog am (msg); Gtk::MessageDialog am (msg);
am.run (); am.run ();
} catch (SessionException e) { } catch (SessionException const& e) {
string msg = string_compose (_("Loading Session script '%1' failed: %2"), spd.name(), e.what ()); string msg = string_compose (_("Loading Session script '%1' failed: %2"), spd.name(), e.what ());
Gtk::MessageDialog am (msg); Gtk::MessageDialog am (msg);
am.run (); am.run ();

View file

@ -464,7 +464,7 @@ LuaWindow::save_script ()
update_gui_state (); // XXX here? update_gui_state (); // XXX here?
append_text (X_("> ") + string_compose (_("Saved as %1"), sb.path)); append_text (X_("> ") + string_compose (_("Saved as %1"), sb.path));
return; // OK return; // OK
} catch (Glib::FileError e) { } catch (Glib::FileError const& e) {
msg = string_compose (_("Error saving file: %1"), e.what()); msg = string_compose (_("Error saving file: %1"), e.what());
goto errorout; goto errorout;
} }
@ -516,7 +516,7 @@ LuaWindow::save_script ()
LuaScripting::instance().refresh (true); LuaScripting::instance().refresh (true);
append_text (X_("> ") + string_compose (_("Saved as %1"), path)); append_text (X_("> ") + string_compose (_("Saved as %1"), path));
return; // OK return; // OK
} catch (Glib::FileError e) { } catch (Glib::FileError const& e) {
msg = string_compose (_("Error saving file: %1"), e.what()); msg = string_compose (_("Error saving file: %1"), e.what());
goto errorout; goto errorout;
} }
@ -743,7 +743,7 @@ LuaWindow::ScriptBuffer::load ()
script = Glib::file_get_contents (path); script = Glib::file_get_contents (path);
flags |= Buffer_Valid; flags |= Buffer_Valid;
flags &= BufferFlags(~Buffer_Dirty); flags &= BufferFlags(~Buffer_Dirty);
} catch (Glib::FileError e) { } catch (Glib::FileError const& e) {
return false; return false;
} }
return true; return true;