From d47442a8b207a812be0f62d93375d66b93a8ab5d Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 31 Jul 2021 17:23:11 +0100 Subject: [PATCH] Control over reporting of fatal errors --- src/GUI/MessageBox.cxx | 14 +++++++++----- src/GUI/MessageBox.hxx | 6 ++++-- src/Main/fg_init.cxx | 6 +++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/GUI/MessageBox.cxx b/src/GUI/MessageBox.cxx index 3514938ab..e08b4b284 100644 --- a/src/GUI/MessageBox.cxx +++ b/src/GUI/MessageBox.cxx @@ -172,10 +172,13 @@ MessageBoxResult modalMessageBox(const std::string& caption, MessageBoxResult fatalMessageBoxWithoutExit(const std::string& caption, const std::string& msg, - const std::string& moreText) + const std::string& moreText, + bool reportToSentry) { - flightgear::sentryReportFatalError(msg, moreText); - + if (reportToSentry) { + flightgear::sentryReportFatalError(msg, moreText); + } + // Headless mode. if (static_isHeadless) { SG_LOG(SG_HEADLESS, SG_ALERT, "Fatal Error: \"" << caption << "\""); @@ -212,9 +215,10 @@ MessageBoxResult fatalMessageBoxWithoutExit(const std::string& caption, const std::string& caption, const std::string& msg, const std::string& moreText, - int exitStatus) + int exitStatus, + bool reportToSentry) { - fatalMessageBoxWithoutExit(caption, msg, moreText); + fatalMessageBoxWithoutExit(caption, msg, moreText, reportToSentry); // we can't use exit() here or QGuiApplication crashes // let's instead throw a sepcial exception which we catch // in boostrap. diff --git a/src/GUI/MessageBox.hxx b/src/GUI/MessageBox.hxx index 057c738aa..66454c2af 100644 --- a/src/GUI/MessageBox.hxx +++ b/src/GUI/MessageBox.hxx @@ -31,13 +31,15 @@ MessageBoxResult modalMessageBox(const std::string& caption, MessageBoxResult fatalMessageBoxWithoutExit( const std::string& caption, const std::string& msg, - const std::string& moreText = std::string()); + const std::string& moreText = std::string(), + bool reportToSentry = true); [[noreturn]] void fatalMessageBoxThenExit( const std::string& caption, const std::string& msg, const std::string& moreText = std::string(), - int exitStatus = EXIT_FAILURE); + int exitStatus = EXIT_FAILURE, + bool reportToSentry = true); } // of namespace flightgear diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index d31abd703..23e4a04a3 100755 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -291,15 +291,19 @@ public: SG_LOG(SG_GENERAL, SG_ALERT, "\tin paths:" << SGPath::join(globals->get_aircraft_paths(), ";")); std::string notFoundMessage; + bool reportToSentry = true; if (globals->get_aircraft_paths().empty()) { notFoundMessage = "The requested aircraft (" + aircraft + ") could not be found. No aircraft paths are configured."; + reportToSentry = false; // no need to log these } else { notFoundMessage = "The requested aircraft (" + aircraft + ") could not be found in any of the search paths."; } flightgear::fatalMessageBoxWithoutExit( "Aircraft not found", - notFoundMessage); + notFoundMessage, + {}, + reportToSentry); return false; }