diff --git a/src/Airports/dynamicloader.cxx b/src/Airports/dynamicloader.cxx index b0caff5e1..c203ed793 100644 --- a/src/Airports/dynamicloader.cxx +++ b/src/Airports/dynamicloader.cxx @@ -67,14 +67,19 @@ void FGGroundNetXMLLoader::endXML () for (it = _parkingPushbacks.begin(); it != _parkingPushbacks.end(); ++it) { NodeIndexMap::const_iterator j = _indexMap.find(it->second); if (j == _indexMap.end()) { - SG_LOG(SG_NAVAID, SG_DEV_WARN, "bad groundnet, no node for index:" << it->first); - continue; + _hasErrors = true; + SG_LOG(SG_NAVAID, SG_DEV_WARN, "bad groundnet, no node for index:" << it->first); + continue; } it->first->setPushBackPoint(j->second); } + if (!_unreferencedNodes.empty()) { + _hasErrors = true; + } + for (const FGTaxiNodeRef& node: _unreferencedNodes) { SG_LOG(SG_NAVAID, SG_DEV_WARN, "unreferenced groundnet node: " << node->getIndex()); @@ -132,6 +137,7 @@ void FGGroundNetXMLLoader::startParking(const XMLAttributes &atts) SG_LOG(SG_NAVAID, SG_DEV_WARN, getPath() << ":" << getLine() << ": " << "invalid value for 'pushBackRoute': " << e.what()); + _hasErrors = true; pushBackRoute = -2; } } @@ -187,6 +193,7 @@ void FGGroundNetXMLLoader::startNode(const XMLAttributes &atts) if (_indexMap.find(index) != _indexMap.end()) { SG_LOG(SG_NAVAID, SG_DEV_WARN, "duplicate ground-net index:" << index); + _hasErrors = true; } SGGeod pos(SGGeod::fromDeg(processPosition(lon), processPosition(lat))); @@ -214,6 +221,7 @@ void FGGroundNetXMLLoader::startArc(const XMLAttributes &atts) IntPair e(begin, end); if (_arcSet.find(e) != _arcSet.end()) { SG_LOG(SG_NAVAID, SG_DEV_WARN, _groundNetwork->airport()->ident() << " ground-net: skipping duplicate edge:" << begin << "->" << end); + _hasErrors = true; return; } @@ -222,6 +230,7 @@ void FGGroundNetXMLLoader::startArc(const XMLAttributes &atts) it = _indexMap.find(begin); if (it == _indexMap.end()) { SG_LOG(SG_NAVAID, SG_DEV_WARN, "ground-net: bad edge:" << begin << "->" << end << ", begin index unknown"); + _hasErrors = true; return; } else { _unreferencedNodes.erase(it->second); @@ -231,6 +240,7 @@ void FGGroundNetXMLLoader::startArc(const XMLAttributes &atts) it = _indexMap.find(end); if (it == _indexMap.end()) { SG_LOG(SG_NAVAID, SG_DEV_WARN, "ground-net: bad edge:" << begin << "->" << end << ", end index unknown"); + _hasErrors = true; return; } else { _unreferencedNodes.erase(it->second); @@ -289,9 +299,9 @@ void FGGroundNetXMLLoader::pi (const char * target, const char * data) { } void FGGroundNetXMLLoader::warning (const char * message, int line, int column) { - SG_LOG(SG_IO, SG_WARN, "Warning: " << message << " (" << line << ',' << column << ')'); + SG_LOG(SG_IO, SG_DEV_WARN, "Warning: " << message << " (" << line << ',' << column << ')'); } void FGGroundNetXMLLoader::error (const char * message, int line, int column) { - SG_LOG(SG_IO, SG_ALERT, "Error: " << message << " (" << line << ',' << column << ')'); + SG_LOG(SG_IO, SG_DEV_ALERT, "Error: " << message << " (" << line << ',' << column << ')'); } diff --git a/src/Airports/dynamicloader.hxx b/src/Airports/dynamicloader.hxx index e9ea587a8..2864a4a49 100644 --- a/src/Airports/dynamicloader.hxx +++ b/src/Airports/dynamicloader.hxx @@ -27,6 +27,11 @@ class FGGroundNetXMLLoader : public XMLVisitor { public: FGGroundNetXMLLoader(FGGroundNetwork* gn); + bool hasErrors() const + { + return _hasErrors; + } + protected: virtual void startXML (); virtual void endXML (); @@ -43,7 +48,10 @@ private: void startArc(const XMLAttributes &atts); FGGroundNetwork* _groundNetwork; - + + // we set this flag if the ground-network has any problems + bool _hasErrors = false; + std::string value; // map from local (groundnet.xml) ids to parking instances diff --git a/src/Airports/xmlloader.cxx b/src/Airports/xmlloader.cxx index 32b9af4ce..6cef87298 100644 --- a/src/Airports/xmlloader.cxx +++ b/src/Airports/xmlloader.cxx @@ -54,39 +54,47 @@ void XMLLoader::load(FGGroundNetwork* net) SGTimeStamp t; t.stamp(); try { - flightgear::sentryThreadReportXMLErrors(false); + flightgear::SentryXMLErrorSupression xs; FGGroundNetXMLLoader visitor(net); readXML(path, visitor); + + if (visitor.hasErrors()) { + flightgear::sentryReportException("Ground-net load error", path.utf8Str()); + } } catch (sg_exception& e) { SG_LOG(SG_NAVAID, SG_DEV_WARN, "parsing groundnet XML failed:" << e.getFormattedMessage()); } - flightgear::sentryThreadReportXMLErrors(true); SG_LOG(SG_NAVAID, SG_DEBUG, "parsing groundnet XML took " << t.elapsedMSec()); } void XMLLoader::loadFromStream(FGGroundNetwork* net, std::istream& inData) { try { - flightgear::sentryThreadReportXMLErrors(false); + flightgear::SentryXMLErrorSupression xs; FGGroundNetXMLLoader visitor(net); readXML(inData, visitor); + + if (visitor.hasErrors()) { + flightgear::sentryReportException("Ground-net load error", {}); + } } catch (sg_exception& e) { SG_LOG(SG_NAVAID, SG_DEV_WARN, "parsing groundnet XML failed:" << e.getFormattedMessage()); } - flightgear::sentryThreadReportXMLErrors(true); } void XMLLoader::loadFromPath(FGGroundNetwork* net, const SGPath& path) { try { - flightgear::sentryThreadReportXMLErrors(false); + flightgear::SentryXMLErrorSupression xs; FGGroundNetXMLLoader visitor(net); readXML(path, visitor); + if (visitor.hasErrors()) { + flightgear::sentryReportException("Ground-net load error", path.utf8Str()); + } } catch (sg_exception& e) { SG_LOG(SG_NAVAID, SG_DEV_WARN, "parsing groundnet XML failed:" << e.getFormattedMessage()); } - flightgear::sentryThreadReportXMLErrors(true); } void XMLLoader::load(FGRunwayPreference* p) {