1
0
Fork 0

Sentry: don't catch cmd-line aircraft init failures

Only worry about mis-config which occur when using the
launcher, since basically all non-launcher ones look to be user errors.
This commit is contained in:
James Turner 2021-08-04 09:53:13 +01:00
parent fc40caf40e
commit 20155df3f6
3 changed files with 25 additions and 6 deletions

View file

@ -197,6 +197,11 @@ public:
{
_cache = autoSave->getNode("sim/startup/path-cache", true);
}
void setDidUseLauncher(bool didUseLauncher)
{
_didUseLauncher = didUseLauncher;
}
/**
* @brief haveExplicitAircraft - check if the combination of /sim/aircraft
@ -292,7 +297,10 @@ public:
SG_LOG(SG_GENERAL, SG_ALERT, "\tin paths:" << SGPath::join(globals->get_aircraft_paths(), ";"));
std::string notFoundMessage;
bool reportToSentry = true;
// don't report failures where the launcher was not used, to Sentry,
// since they are nearly all configuration problems.
bool reportToSentry = _didUseLauncher;
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
@ -445,7 +453,8 @@ private:
std::string _searchAircraft;
SGPath _foundPath;
SGPropertyNode* _cache;
SGPropertyNode* _cache = nullptr;
bool _didUseLauncher = false;
};
#ifdef _WIN32
@ -758,7 +767,7 @@ void fgInitAircraftPaths(bool reinit)
}
}
int fgInitAircraft(bool reinit)
int fgInitAircraft(bool reinit, bool didUseLauncher)
{
if (!reinit) {
auto r = flightgear::Options::sharedInstance()->initAircraft();
@ -767,6 +776,7 @@ int fgInitAircraft(bool reinit)
}
FindAndCacheAircraft f(globals->get_props());
f.setDidUseLauncher(didUseLauncher);
const bool haveExplicit = f.haveExplicitAircraft();
SGSharedPtr<Root> pkgRoot(globals->packageRoot());
@ -1367,7 +1377,7 @@ void fgStartNewReset()
fgGetNode("/sim")->removeChild("aircraft-dir");
fgInitAircraftPaths(true);
fgInitAircraft(true);
fgInitAircraft(true, false /* not from launcher */);
render = new FGRenderer(composite_viewer);
render->setEventHandler(eventHandler);

View file

@ -54,7 +54,14 @@ int fgInitConfig ( int argc, char **argv, bool reinit );
void fgInitAircraftPaths(bool reinit);
int fgInitAircraft(bool reinit);
/**
* @brief
*
* @param reinit : is this a second(+) call of the function, i.e after reset
* @param didUseLauncher : allow adjusting UI feedback if we used the launcher or not
* @return int : an Options result to indicate if we should continue, quit, etc
*/
int fgInitAircraft(bool reinit, bool didUseLauncher);
// log various settings / configuration state
void fgOutputSettings();

View file

@ -711,6 +711,7 @@ int fgMainInit( int argc, char **argv )
return EXIT_SUCCESS;
}
bool didUseLauncher = false;
#if defined(HAVE_QT)
if (showLauncher) {
flightgear::addSentryBreadcrumb("starting launcher", "info");
@ -718,6 +719,7 @@ int fgMainInit( int argc, char **argv )
return EXIT_SUCCESS;
}
didUseLauncher = true;
flightgear::addSentryBreadcrumb("completed launcher", "info");
}
#else
@ -732,7 +734,7 @@ int fgMainInit( int argc, char **argv )
auto errorManager = globals->add_new_subsystem<flightgear::ErrorReporter>(SGSubsystemMgr::GENERAL);
errorManager->preinit();
configResult = fgInitAircraft(false);
configResult = fgInitAircraft(false, didUseLauncher);
if (configResult == flightgear::FG_OPTIONS_ERROR) {
return EXIT_FAILURE;
} else if ((configResult == flightgear::FG_OPTIONS_EXIT) ||