Catch exceptions when launching external editor

Catch all Glib::Errors and print the error code and message to stderr.
This commit is contained in:
Lawrence Lee 2021-07-11 22:13:27 -07:00
parent 02e3e01294
commit c4a8554db3

View File

@ -342,5 +342,13 @@ bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName)
bool ExtProgStore::openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr<Gio::AppInfo> &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;
}
}