From c4a8554db3da65d50497703ccd4951dbb16a86b9 Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Sun, 11 Jul 2021 22:13:27 -0700 Subject: [PATCH] Catch exceptions when launching external editor Catch all Glib::Errors and print the error code and message to stderr. --- rtgui/extprog.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rtgui/extprog.cc b/rtgui/extprog.cc index 148eee944..e4cf63733 100644 --- a/rtgui/extprog.cc +++ b/rtgui/extprog.cc @@ -342,5 +342,13 @@ bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName) bool ExtProgStore::openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr &editorInfo) { - return editorInfo->launch(Gio::File::create_for_path(fileName)); + try { + return editorInfo->launch(Gio::File::create_for_path(fileName)); + } catch (const Glib::Error &e) { + std::cerr + << "Error launching external editor.\n" + << "Error code #" << e.code() << ": " << e.what() + << std::endl; + return false; + } }