From 2ad9e96aebc0f341b6426cc8da13036f922dd7c1 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Tue, 2 Nov 2021 19:29:27 +0100
Subject: [PATCH] Throw exception if a child in DetElement is not present

---
 DDCore/src/DetElement.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/DDCore/src/DetElement.cpp b/DDCore/src/DetElement.cpp
index aa0eedd27..c4b0d599e 100644
--- a/DDCore/src/DetElement.cpp
+++ b/DDCore/src/DetElement.cpp
@@ -214,9 +214,10 @@ DetElement DetElement::child(const string& child_name) const {
   if (isValid()) {
     const Children& c = ptr()->children;
     Children::const_iterator i = c.find(child_name);
-    return i == c.end() ? DetElement() : (*i).second;
+    if ( i != c.end() ) return (*i).second;
+    throw runtime_error("dd4hep: DetElement::child Unknown child with name: "+child_name);
   }
-  return DetElement();
+  throw runtime_error("dd4hep: DetElement::child: Self is not defined [Invalid Handle]");
 }
 
 /// Access to the detector elements's parent
-- 
GitLab