1
0
Fork 0

Control over reporting of fatal errors

This commit is contained in:
James Turner 2021-07-31 17:23:11 +01:00
parent 66b5c4259e
commit d47442a8b2
3 changed files with 18 additions and 8 deletions

View file

@ -172,9 +172,12 @@ MessageBoxResult modalMessageBox(const std::string& caption,
MessageBoxResult fatalMessageBoxWithoutExit(const std::string& caption, MessageBoxResult fatalMessageBoxWithoutExit(const std::string& caption,
const std::string& msg, const std::string& msg,
const std::string& moreText) const std::string& moreText,
bool reportToSentry)
{ {
if (reportToSentry) {
flightgear::sentryReportFatalError(msg, moreText); flightgear::sentryReportFatalError(msg, moreText);
}
// Headless mode. // Headless mode.
if (static_isHeadless) { if (static_isHeadless) {
@ -212,9 +215,10 @@ MessageBoxResult fatalMessageBoxWithoutExit(const std::string& caption,
const std::string& caption, const std::string& caption,
const std::string& msg, const std::string& msg,
const std::string& moreText, 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 // we can't use exit() here or QGuiApplication crashes
// let's instead throw a sepcial exception which we catch // let's instead throw a sepcial exception which we catch
// in boostrap. // in boostrap.

View file

@ -31,13 +31,15 @@ MessageBoxResult modalMessageBox(const std::string& caption,
MessageBoxResult fatalMessageBoxWithoutExit( MessageBoxResult fatalMessageBoxWithoutExit(
const std::string& caption, const std::string& caption,
const std::string& msg, const std::string& msg,
const std::string& moreText = std::string()); const std::string& moreText = std::string(),
bool reportToSentry = true);
[[noreturn]] void fatalMessageBoxThenExit( [[noreturn]] void fatalMessageBoxThenExit(
const std::string& caption, const std::string& caption,
const std::string& msg, const std::string& msg,
const std::string& moreText = std::string(), const std::string& moreText = std::string(),
int exitStatus = EXIT_FAILURE); int exitStatus = EXIT_FAILURE,
bool reportToSentry = true);
} // of namespace flightgear } // of namespace flightgear

View file

@ -291,15 +291,19 @@ public:
SG_LOG(SG_GENERAL, SG_ALERT, "\tin paths:" << SGPath::join(globals->get_aircraft_paths(), ";")); SG_LOG(SG_GENERAL, SG_ALERT, "\tin paths:" << SGPath::join(globals->get_aircraft_paths(), ";"));
std::string notFoundMessage; std::string notFoundMessage;
bool reportToSentry = true;
if (globals->get_aircraft_paths().empty()) { if (globals->get_aircraft_paths().empty()) {
notFoundMessage = "The requested aircraft (" + aircraft + ") could not be found. No aircraft paths are configured."; notFoundMessage = "The requested aircraft (" + aircraft + ") could not be found. No aircraft paths are configured.";
reportToSentry = false; // no need to log these
} else { } else {
notFoundMessage = "The requested aircraft (" + aircraft + ") could not be found in any of the search paths."; notFoundMessage = "The requested aircraft (" + aircraft + ") could not be found in any of the search paths.";
} }
flightgear::fatalMessageBoxWithoutExit( flightgear::fatalMessageBoxWithoutExit(
"Aircraft not found", "Aircraft not found",
notFoundMessage); notFoundMessage,
{},
reportToSentry);
return false; return false;
} }