From 32249d140f9c1c8a6c167454ab8516db936ffd51 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Wed, 1 May 2024 20:37:57 -0400 Subject: [PATCH] Better exception handling in JFactory Inspired by the failing Podio test cases --- src/libraries/JANA/JFactory.cc | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/libraries/JANA/JFactory.cc b/src/libraries/JANA/JFactory.cc index d19980f6e..d3c412c47 100644 --- a/src/libraries/JANA/JFactory.cc +++ b/src/libraries/JANA/JFactory.cc @@ -24,6 +24,15 @@ void JFactory::Create(const std::shared_ptr& event) { if (ex.factory_tag.empty()) ex.factory_tag = mTag; throw ex; } + catch (std::exception& e) { + auto ex = JException("Exception in JFactoryT::Init(): %s", e.what()); + ex.nested_exception = std::current_exception(); + ex.plugin_name = mPluginName; + ex.component_name = mFactoryName; + ex.factory_name = mFactoryName; + ex.factory_tag = mTag; + throw ex; + } catch (...) { auto ex = JException("Unknown exception in JFactoryT::Init()"); ex.nested_exception = std::current_exception(); @@ -63,8 +72,17 @@ void JFactory::Create(const std::shared_ptr& event) { if (ex.factory_tag.empty()) ex.factory_tag = mTag; throw ex; } + catch (std::exception& e) { + auto ex = JException("Exception in JFactory::BeginRun/ChangeRun/EndRun(): %s", e.what()); + ex.nested_exception = std::current_exception(); + ex.plugin_name = mPluginName; + ex.component_name = mFactoryName; + ex.factory_name = mFactoryName; + ex.factory_tag = mTag; + throw ex; + } catch (...) { - auto ex = JException("Unknown exception in JFactoryT::BeginRun/ChangeRun/EndRun()"); + auto ex = JException("Unknown exception in JFactory::BeginRun/ChangeRun/EndRun()"); ex.nested_exception = std::current_exception(); ex.plugin_name = mPluginName; ex.component_name = mFactoryName; @@ -82,8 +100,17 @@ void JFactory::Create(const std::shared_ptr& event) { if (ex.factory_tag.empty()) ex.factory_tag = mTag; throw ex; } + catch (std::exception& e) { + auto ex = JException("Exception in JFactory::Process(): %s", e.what()); + ex.nested_exception = std::current_exception(); + ex.plugin_name = mPluginName; + ex.component_name = mFactoryName; + ex.factory_name = mFactoryName; + ex.factory_tag = mTag; + throw ex; + } catch (...) { - auto ex = JException("Unknown exception in JFactoryT::Process()"); + auto ex = JException("Unknown exception in JFactory::Process()"); ex.nested_exception = std::current_exception(); ex.plugin_name = mPluginName; ex.component_name = mFactoryName;