13
0

Improved reporting of glib throw errors during session creation

This commit is contained in:
Todd Naugle 2022-02-23 17:32:09 -06:00
parent 2217e8d9ce
commit dd1156e900

View File

@ -36,6 +36,8 @@
#include "gtk2ardour-version.h"
#endif
#include <glibmm/error.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/stock.h>
@ -443,6 +445,37 @@ ARDOUR_UI::load_session_stage_two (const std::string& path, const std::string& s
goto out;
}
catch (Glib::Error const& e) {
const std::string& glib_what = e.what();
gchar* escaped_error_txt = 0;
stringstream ss;
dump_errors (ss, 6);
dump_errors (cerr);
clear_errors ();
{
const std::string& tmp = ss.str();
escaped_error_txt = g_markup_escape_text (tmp.c_str(), -1);
}
ArdourMessageDialog msg (string_compose(
_("Session \"%1 (snapshot %2)\" did not load successfully.\nGlib Error\nDomain: %3\nCode: %4\nWhat: %5\n%6%7"),
path, snap_name,
g_quark_to_string(e.domain()), e.code(), glib_what.c_str(),
ss.str().empty() ? "" : "\n\n---", escaped_error_txt),
true,
Gtk::MESSAGE_INFO,
BUTTONS_OK);
msg.set_title (_("Loading Error"));
msg.set_position (Gtk::WIN_POS_CENTER);
(void) msg.run ();
msg.hide ();
delete escaped_error_txt;
goto out;
}
catch (...) {
gchar* escaped_error_txt = 0;
stringstream ss;
@ -667,6 +700,30 @@ ARDOUR_UI::build_session_stage_two (std::string const& path, std::string const&
delete escaped_error_txt;
return -1;
}
catch (Glib::Error const& e) {
const std::string& glib_what = e.what();
gchar* escaped_error_txt = 0;
stringstream ss;
dump_errors (ss, 6);
dump_errors (cerr);
clear_errors ();
{
const std::string& tmp = ss.str();
escaped_error_txt = g_markup_escape_text (tmp.c_str(), -1);
}
ArdourMessageDialog msg (string_compose(
_("Could not create session in \"%1\":.\nGlib Error\nDomain: %2\nCode: %3\nWhat: %4\n%5%6"),
path,
g_quark_to_string(e.domain()), e.code(), glib_what.c_str(),
ss.str().empty() ? "" : "\n\n---", escaped_error_txt));
msg.set_title (_("Loading Error"));
msg.set_position (Gtk::WIN_POS_CENTER);
msg.run ();
delete escaped_error_txt;
return -1;
}
catch (...) {
gchar* escaped_error_txt = 0;
stringstream ss;