Control over reporting of fatal errors
This commit is contained in:
parent
66b5c4259e
commit
d47442a8b2
3 changed files with 18 additions and 8 deletions
|
@ -172,9 +172,12 @@ 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)
|
||||
{
|
||||
if (reportToSentry) {
|
||||
flightgear::sentryReportFatalError(msg, moreText);
|
||||
}
|
||||
|
||||
// Headless mode.
|
||||
if (static_isHeadless) {
|
||||
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue