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,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.

View file

@ -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

View file

@ -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;
}