From be50f6482121d0e4d01ecb839eea5aa518454d34 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Tue, 10 Nov 2020 11:11:27 +0000 Subject: [PATCH] =?UTF-8?q?FlightPlan:=20don=E2=80=99t=20use=20exceptions?= =?UTF-8?q?=20for=20load=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid spamming Sentry when loading problem flight-plans. --- src/Navaids/FlightPlan.cxx | 22 ++++++++++++++++------ src/Navaids/FlightPlan.hxx | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Navaids/FlightPlan.cxx b/src/Navaids/FlightPlan.cxx index 421494c90..06be225df 100644 --- a/src/Navaids/FlightPlan.cxx +++ b/src/Navaids/FlightPlan.cxx @@ -1081,14 +1081,16 @@ bool FlightPlan::loadXmlFormat(const SGPath& path) { try { int version = routeData->getIntValue("version", 1); + bool ok = false; if (version == 1) { - loadVersion1XMLRoute(routeData); + ok = loadVersion1XMLRoute(routeData); } else if (version == 2) { - loadVersion2XMLRoute(routeData); + ok = loadVersion2XMLRoute(routeData); } else { - throw sg_io_exception("unsupported XML route version"); + SG_LOG(SG_NAVAID, SG_POPUP, "Unsupported flight plan version " << version << " loading " << path); } - return true; + + return ok; } catch (sg_exception& e) { SG_LOG(SG_NAVAID, SG_ALERT, "Failed to load flight-plan '" << e.getOrigin() << "'. " << e.getMessage()); @@ -1188,8 +1190,11 @@ void FlightPlan::loadXMLRouteHeader(SGPropertyNode_ptr routeData) } // of cruise data loading } -void FlightPlan::loadVersion2XMLRoute(SGPropertyNode_ptr routeData) +bool FlightPlan::loadVersion2XMLRoute(SGPropertyNode_ptr routeData) { + if (!routeData->hasChild("route")) + return false; + loadXMLRouteHeader(routeData); // route nodes @@ -1219,10 +1224,14 @@ void FlightPlan::loadVersion2XMLRoute(SGPropertyNode_ptr routeData) } // of route iteration } _waypointsChanged = true; + return true; } -void FlightPlan::loadVersion1XMLRoute(SGPropertyNode_ptr routeData) +bool FlightPlan::loadVersion1XMLRoute(SGPropertyNode_ptr routeData) { + if (!routeData->hasChild("route")) + return false; + loadXMLRouteHeader(routeData); // _legs nodes @@ -1234,6 +1243,7 @@ void FlightPlan::loadVersion1XMLRoute(SGPropertyNode_ptr routeData) _legs.push_back(l); } // of route iteration _waypointsChanged = true; + return true; } WayptRef FlightPlan::parseVersion1XMLWaypt(SGPropertyNode* aWP) diff --git a/src/Navaids/FlightPlan.hxx b/src/Navaids/FlightPlan.hxx index 3b5a0de49..40a30fed4 100644 --- a/src/Navaids/FlightPlan.hxx +++ b/src/Navaids/FlightPlan.hxx @@ -420,8 +420,8 @@ private: bool loadGpxFormat(const SGPath& path); bool loadPlainTextFormat(const SGPath& path); - void loadVersion1XMLRoute(SGPropertyNode_ptr routeData); - void loadVersion2XMLRoute(SGPropertyNode_ptr routeData); + bool loadVersion1XMLRoute(SGPropertyNode_ptr routeData); + bool loadVersion2XMLRoute(SGPropertyNode_ptr routeData); void loadXMLRouteHeader(SGPropertyNode_ptr routeData); WayptRef parseVersion1XMLWaypt(SGPropertyNode* aWP);