From 8220a50be6bcbddf179bb855b2f7d36436fcca6b Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 7 Dec 2018 16:41:40 +0100 Subject: More gracefully handle config errors in geometries --- src/ConeProjectionGeometry3D.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ConeProjectionGeometry3D.cpp') diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp index 90adfa8..8022591 100644 --- a/src/ConeProjectionGeometry3D.cpp +++ b/src/ConeProjectionGeometry3D.cpp @@ -88,13 +88,21 @@ bool CConeProjectionGeometry3D::initialize(const Config& _cfg) // Required: DistanceOriginDetector XMLNode node = _cfg.self.getSingleNode("DistanceOriginDetector"); ASTRA_CONFIG_CHECK(node, "ConeProjectionGeometry3D", "No DistanceOriginDetector tag specified."); - m_fOriginDetectorDistance = node.getContentNumerical(); + try { + m_fOriginDetectorDistance = node.getContentNumerical(); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "ConeProjectionGeometry3D", "DistanceOriginDetector must be numerical."); + } CC.markNodeParsed("DistanceOriginDetector"); // Required: DetectorOriginSource node = _cfg.self.getSingleNode("DistanceOriginSource"); ASTRA_CONFIG_CHECK(node, "ConeProjectionGeometry3D", "No DistanceOriginSource tag specified."); - m_fOriginSourceDistance = node.getContentNumerical(); + try { + m_fOriginSourceDistance = node.getContentNumerical(); + } catch (const StringUtil::bad_cast &e) { + ASTRA_CONFIG_CHECK(false, "ConeProjectionGeometry3D", "DistanceOriginSource must be numerical."); + } CC.markNodeParsed("DistanceOriginSource"); // success -- cgit v1.2.3