Add error reporting to common failure points.
Not exhaustive by far, but adds many of the common failure points witnessed on Sentry.
This commit is contained in:
parent
a0ff4adbc6
commit
caad29e7c8
9 changed files with 138 additions and 56 deletions
|
@ -21,12 +21,13 @@
|
|||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/structure/SGBinding.hxx>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#include <Add-ons/AddonManager.hxx>
|
||||
#include <Airports/airport.hxx>
|
||||
|
@ -74,9 +75,15 @@ public:
|
|||
if (!loadScript.empty()) {
|
||||
FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
|
||||
std::string moduleName = "scenario_" + _internalName;
|
||||
nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
|
||||
bool ok = nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
|
||||
loadScript.c_str(), loadScript.size(),
|
||||
nullptr);
|
||||
|
||||
if (!ok) {
|
||||
// TODO: get the Nasal errors logged properly
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::ScenarioLoad,
|
||||
"Failed to parse scenario Nasal");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,8 +220,10 @@ SGPropertyNode_ptr FGAIManager::registerScenarioFile(SGPropertyNode_ptr root, co
|
|||
auto scenariosNode = root->getNode("/sim/ai/scenarios", true);
|
||||
SGPropertyNode_ptr sNode;
|
||||
|
||||
simgear::ErrorReportContext ectx("scenario", xmlPath.utf8Str());
|
||||
|
||||
// don't report XML errors while loading scenarios, to Sentry
|
||||
flightgear::sentryThreadReportXMLErrors(false);
|
||||
flightgear::SentryXMLErrorSupression xml;
|
||||
|
||||
try {
|
||||
SGPropertyNode_ptr scenarioProps(new SGPropertyNode);
|
||||
|
@ -246,12 +255,14 @@ SGPropertyNode_ptr FGAIManager::registerScenarioFile(SGPropertyNode_ptr root, co
|
|||
|
||||
FGAICarrier::extractCarriersFromScenario(xs, sNode);
|
||||
} // of scenarios in the XML file
|
||||
} catch (std::exception&) {
|
||||
} catch (sg_exception& e) {
|
||||
SG_LOG(SG_AI, SG_WARN, "Skipping malformed scenario file:" << xmlPath);
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::ScenarioLoad,
|
||||
string{"The scenario couldn't be loaded:"} + e.getFormattedMessage(),
|
||||
e.getLocation());
|
||||
sNode.reset();
|
||||
}
|
||||
|
||||
flightgear::sentryThreadReportXMLErrors(true);
|
||||
return sNode;
|
||||
}
|
||||
|
||||
|
@ -590,6 +601,7 @@ FGAIBasePtr FGAIManager::getObjectFromProperty(const SGPropertyNode* aProp) cons
|
|||
bool
|
||||
FGAIManager::loadScenario( const string &id )
|
||||
{
|
||||
simgear::ErrorReportContext("scenario", id);
|
||||
SGPropertyNode_ptr file = loadScenarioFile(id);
|
||||
if (!file) {
|
||||
return false;
|
||||
|
@ -647,6 +659,9 @@ FGAIManager::loadScenarioFile(const std::string& scenarioName)
|
|||
auto s = fgGetNode("/sim/ai/scenarios");
|
||||
if (!s) return {};
|
||||
|
||||
// don't report XML errors while loading scenarios, to Sentry
|
||||
flightgear::SentryXMLErrorSupression xml;
|
||||
|
||||
for (auto n : s->getChildren("scenario")) {
|
||||
if (n->getStringValue("id") == scenarioName) {
|
||||
SGPath path{n->getStringValue("path")};
|
||||
|
@ -657,6 +672,9 @@ FGAIManager::loadScenarioFile(const std::string& scenarioName)
|
|||
} catch (const sg_exception &t) {
|
||||
SG_LOG(SG_AI, SG_ALERT, "Failed to load scenario '"
|
||||
<< path << "': " << t.getFormattedMessage());
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::ScenarioLoad,
|
||||
"Failed to laod scenario XML:" + t.getFormattedMessage(),
|
||||
t.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,13 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/sentryIntegration.hxx>
|
||||
|
||||
using std::vector;
|
||||
using simgear::PropertyList;
|
||||
|
@ -189,12 +192,12 @@ void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string& name,
|
|||
SGPath config = globals->resolve_maybe_aircraft_path(path);
|
||||
if( config.isNull() )
|
||||
{
|
||||
SG_LOG
|
||||
(
|
||||
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::AircraftSystems,
|
||||
string{"Autopilot XML not found:"} + path, sg_location{path});
|
||||
SG_LOG(
|
||||
SG_AUTOPILOT,
|
||||
SG_ALERT,
|
||||
"Cannot find property-rule configuration file '" << path << "'."
|
||||
);
|
||||
"Cannot find property-rule configuration file '" << path << "'.");
|
||||
return;
|
||||
}
|
||||
SG_LOG
|
||||
|
@ -206,6 +209,8 @@ void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string& name,
|
|||
|
||||
try
|
||||
{
|
||||
flightgear::SentryXMLErrorSupression xmlc;
|
||||
|
||||
SGPropertyNode_ptr configNode = new SGPropertyNode();
|
||||
readProperties(config, configNode);
|
||||
|
||||
|
@ -221,6 +226,8 @@ void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string& name,
|
|||
"Failed to load property-rule configuration: " << config
|
||||
<< ": " << e.getMessage()
|
||||
);
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::AircraftSystems,
|
||||
string{"Autopilot XML faield to load:"} + e.getFormattedMessage(), e.getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#include <Add-ons/AddonManager.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/sentryIntegration.hxx>
|
||||
|
||||
#if defined(SG_UNIX) && !defined(SG_MAC)
|
||||
#include "GL/glx.h"
|
||||
|
@ -207,9 +209,13 @@ NewGUI::showDialog (const string &name)
|
|||
|
||||
// check we know about the dialog by name
|
||||
if (_dialog_names.find(name) == _dialog_names.end()) {
|
||||
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::GUIDialog, "Dialog not found:" + name);
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Dialog " << name << " not defined");
|
||||
return false;
|
||||
}
|
||||
|
||||
flightgear::addSentryBreadcrumb("showing GUI dialog:" + name, "info");
|
||||
|
||||
_active_dialogs[name] = new FGPUIDialog(getDialogProperties(name));
|
||||
fgSetString("/sim/gui/dialogs/current-dialog", name);
|
||||
|
||||
|
@ -261,6 +267,8 @@ bool
|
|||
NewGUI::closeDialog (const string& name)
|
||||
{
|
||||
if(_active_dialogs.find(name) != _active_dialogs.end()) {
|
||||
flightgear::addSentryBreadcrumb("closing GUI dialog:" + name, "info");
|
||||
|
||||
if(_active_dialog == _active_dialogs[name])
|
||||
_active_dialog = 0;
|
||||
delete _active_dialogs[name];
|
||||
|
|
|
@ -28,11 +28,13 @@
|
|||
|
||||
#include "FGDeviceConfigurationMap.hxx"
|
||||
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/sentryIntegration.hxx>
|
||||
#include <Navaids/NavDataCache.hxx>
|
||||
|
||||
using simgear::PropertyList;
|
||||
|
@ -158,12 +160,18 @@ void FGDeviceConfigurationMap::readCachedData(const SGPath& path)
|
|||
|
||||
void FGDeviceConfigurationMap::refreshCacheForFile(const SGPath& path)
|
||||
{
|
||||
simgear::ErrorReportContext ectx("input-device", path.utf8Str());
|
||||
|
||||
SG_LOG(SG_INPUT, SG_DEBUG, "Reading device file " << path);
|
||||
SGPropertyNode_ptr n(new SGPropertyNode);
|
||||
flightgear::SentryXMLErrorSupression dontReportXmlErrors;
|
||||
try {
|
||||
readProperties(path, n);
|
||||
} catch (sg_exception&) {
|
||||
} catch (sg_exception& e) {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "parse failure reading:" << path);
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::InputDeviceConfig,
|
||||
"Failed to load input device configuration:" + e.getFormattedMessage(),
|
||||
path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
#include "FGDeviceConfigurationMap.hxx"
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Scripting/NasalSys.hxx>
|
||||
|
@ -202,6 +204,9 @@ void FGJoystickInput::postinit()
|
|||
if (!js_node || js->notWorking())
|
||||
continue;
|
||||
|
||||
// FIXME : need to get input device path to disambiguate
|
||||
simgear::ErrorReportContext errCtx("input-device", "");
|
||||
|
||||
#ifdef WIN32
|
||||
JOYCAPS jsCaps ;
|
||||
joyGetDevCaps( i, &jsCaps, sizeof(jsCaps) );
|
||||
|
@ -244,7 +249,12 @@ void FGJoystickInput::postinit()
|
|||
unsigned int j;
|
||||
for (j = 0; j < nasal.size(); j++) {
|
||||
nasal[j]->setStringValue("module", module.c_str());
|
||||
nasalsys->handleCommand(nasal[j],nullptr);
|
||||
bool ok = nasalsys->handleCommand(nasal[j], nullptr);
|
||||
if (!ok) {
|
||||
// TODO: get the Nasal errors logged properly
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::InputDeviceConfig,
|
||||
"Failed to parse input device Nasal");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -11,16 +11,18 @@
|
|||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/io/iostreams/sgstream.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/structure/event_mgr.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/timing/sg_time.hxx>
|
||||
|
||||
#include <Network/RemoteXMLRequest.hxx>
|
||||
|
||||
#include <FDM/flight.hxx>
|
||||
|
@ -817,6 +819,8 @@ do_load_xml_to_proptree(const SGPropertyNode * arg, SGPropertyNode * root)
|
|||
{
|
||||
if (!quiet) {
|
||||
SG_LOG(SG_IO, SG_ALERT, "loadxml: Cannot find XML property file '" << file << "'.");
|
||||
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::XMLLoadCommand,
|
||||
"loadxml: no such file:" + file.utf8Str(), file);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -825,6 +829,8 @@ do_load_xml_to_proptree(const SGPropertyNode * arg, SGPropertyNode * root)
|
|||
if (!XMLLoader::findAirportData(icao, file.utf8Str(), file)) {
|
||||
if (!quiet) {
|
||||
SG_LOG(SG_IO, SG_INFO, "loadxml: failed to find airport data for " << file << " at ICAO:" << icao);
|
||||
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::XMLLoadCommand,
|
||||
"loadxml: no airprot data file for:" + icao, file);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -852,15 +858,17 @@ do_load_xml_to_proptree(const SGPropertyNode * arg, SGPropertyNode * root)
|
|||
|
||||
// don't report Sentry errors for Nasal-loaded XML, since it makes
|
||||
// for very noisy reports
|
||||
flightgear::sentryThreadReportXMLErrors(false);
|
||||
flightgear::SentryXMLErrorSupression xmls;
|
||||
try {
|
||||
readProperties(validated_path, targetnode, true);
|
||||
} catch (const sg_exception &e) {
|
||||
if (!quiet) {
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::XMLLoadCommand,
|
||||
"loadxml exception:" + e.getFormattedMessage(), e.getLocation());
|
||||
}
|
||||
SG_LOG(SG_IO, quiet ? SG_DEV_WARN : SG_WARN, "loadxml exception: " << e.getFormattedMessage());
|
||||
flightgear::sentryThreadReportXMLErrors(true);
|
||||
return false;
|
||||
}
|
||||
flightgear::sentryThreadReportXMLErrors(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
#include <cstring> // for strcmp()
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/scene/model/placement.hxx>
|
||||
|
@ -74,13 +76,20 @@ FGAircraftModel::init ()
|
|||
return;
|
||||
}
|
||||
|
||||
simgear::ErrorReportContext ec("primary-aircraft", "yes");
|
||||
|
||||
SGPropertyNode_ptr sim = fgGetNode("/sim", true);
|
||||
for (auto model : sim->getChildren("model")) {
|
||||
std::string path = model->getStringValue("path", "Models/Geometry/glider.ac");
|
||||
std::string usage = model->getStringValue("usage", "external");
|
||||
|
||||
simgear::ErrorReportContext ec("aircraft-model", path);
|
||||
|
||||
SGPath resolvedPath = globals->resolve_aircraft_path(path);
|
||||
if (resolvedPath.isNull()) {
|
||||
simgear::reportFailure(simgear::LoadFailure::NotFound,
|
||||
simgear::ErrorCode::XMLModelLoad,
|
||||
"Failed to find aircraft model", SGPath::fromUtf8(path));
|
||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to find aircraft model: " << path);
|
||||
continue;
|
||||
}
|
||||
|
@ -89,6 +98,10 @@ FGAircraftModel::init ()
|
|||
try {
|
||||
node = fgLoad3DModelPanel( resolvedPath, globals->get_props());
|
||||
} catch (const sg_exception &ex) {
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData,
|
||||
simgear::ErrorCode::XMLModelLoad,
|
||||
"Failed to load aircraft model:" + ex.getFormattedMessage(),
|
||||
ex.getLocation());
|
||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to load aircraft from " << path << ':');
|
||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, " " << ex.getFormattedMessage());
|
||||
}
|
||||
|
|
|
@ -33,19 +33,20 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <simgear/nasal/nasal.h>
|
||||
#include <simgear/nasal/iolib.h>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/io/iostreams/sgstream.hxx>
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
#include <simgear/misc/SimpleMarkdown.hxx>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
#include <simgear/structure/event_mgr.hxx>
|
||||
#include <simgear/debug/BufferedLogCallback.hxx>
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/io/iostreams/sgstream.hxx>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/misc/SimpleMarkdown.hxx>
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
#include <simgear/nasal/iolib.h>
|
||||
#include <simgear/nasal/nasal.h>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/structure/event_mgr.hxx>
|
||||
|
||||
#include <simgear/nasal/cppbind/from_nasal.hxx>
|
||||
#include <simgear/nasal/cppbind/to_nasal.hxx>
|
||||
|
|
|
@ -31,14 +31,16 @@
|
|||
|
||||
#include "fg_fx.hxx"
|
||||
|
||||
#include <algorithm>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/sentryIntegration.hxx>
|
||||
#include <Sound/soundmanager.hxx>
|
||||
#include <algorithm>
|
||||
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/sound/xmlsound.hxx>
|
||||
|
||||
FGFX::FGFX ( const std::string &refname, SGPropertyNode *props ) :
|
||||
|
@ -120,6 +122,8 @@ FGFX::init()
|
|||
SGPath path = globals->resolve_aircraft_path(path_str);
|
||||
if (path.isNull())
|
||||
{
|
||||
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::AudioFX,
|
||||
"Failed to find FX XML file:" + path_str, sg_location{path_str});
|
||||
SG_LOG(SG_SOUND, SG_ALERT,
|
||||
"File not found: '" << path_str);
|
||||
return;
|
||||
|
@ -129,8 +133,11 @@ FGFX::init()
|
|||
|
||||
SGPropertyNode root;
|
||||
try {
|
||||
flightgear::SentryXMLErrorSupression xmls;
|
||||
readProperties(path, &root);
|
||||
} catch (const sg_exception &) {
|
||||
} catch (const sg_exception& e) {
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::AudioFX,
|
||||
"Failure loading FX XML:" + e.getFormattedMessage(), e.getLocation());
|
||||
SG_LOG(SG_SOUND, SG_ALERT,
|
||||
"Error reading file '" << path << '\'');
|
||||
return;
|
||||
|
@ -150,6 +157,8 @@ FGFX::init()
|
|||
}
|
||||
} catch ( sg_exception &e ) {
|
||||
SG_LOG(SG_SOUND, SG_ALERT, e.getFormattedMessage());
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::AudioFX,
|
||||
"Failure creating Audio FX:" + e.getFormattedMessage(), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue