From d3d3d18b69c050cb6502639ed7faf13aff7850ae Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 26 Nov 2021 10:58:51 +0100
Subject: [PATCH] Remove another occurrency of a call to G4::GetPropertyIndex()
 with 2nd. argument

---
 DDG4/src/Geant4Converter.cpp | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp
index db8301d59..18df9d9a2 100644
--- a/DDG4/src/Geant4Converter.cpp
+++ b/DDG4/src/Geant4Converter.cpp
@@ -385,7 +385,6 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const
         tab = new G4MaterialPropertiesTable();
         mat->SetMaterialPropertiesTable(tab);
       }
-      string err;
       int idx = -1;
       try   {
         idx = tab->GetPropertyIndex(named->GetName());
@@ -1185,6 +1184,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const    {
     G4MaterialPropertiesTable* tab = 0;
     TListIter it(&optSurf->GetProperties());
     for(TObject* obj = it.Next(); obj; obj = it.Next())  {
+      string exc_str;
       TNamed*      named = (TNamed*)obj;
       TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle());
       if ( 0 == tab )  {
@@ -1197,9 +1197,21 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const    {
         except("Geant4OpticalSurface","++ Failed to convert opt.surface %s. Property table %s is not defined!",
                optSurf->GetName(), named->GetTitle());
       }
-      int idx = tab->GetPropertyIndex(named->GetName(), false);
+      int idx = -1;
+      try   {
+        idx = tab->GetPropertyIndex(named->GetName());
+      }
+      catch(const std::exception& e)   {
+        exc_str = e.what();
+        idx = -1;
+      }
+      catch(...)   {
+        idx = -1;
+      }
       if ( idx < 0 )   {
-        printout(ERROR, "Geant4Converter", "++ UNKNOWN Geant4 Property: %-20s [IGNORED]", named->GetName());
+        printout(ERROR, "Geant4Converter",
+                 "++ UNKNOWN Geant4 Property: %-20s %s [IGNORED]",
+                 exc_str.c_str(), named->GetName());
         continue;
       }
       // We need to convert the property from TGeo units to Geant4 units
-- 
GitLab