From 5ae2275238bcca1d65760dd678bdc14506db723b Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Tue, 21 Nov 2023 14:01:44 -0500 Subject: [PATCH] JMultifactory catches std::exception and rethrows as a JException --- src/libraries/JANA/JMultifactory.cc | 49 +++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/libraries/JANA/JMultifactory.cc b/src/libraries/JANA/JMultifactory.cc index 745663fc5..2a215a834 100644 --- a/src/libraries/JANA/JMultifactory.cc +++ b/src/libraries/JANA/JMultifactory.cc @@ -16,23 +16,60 @@ void JMultifactory::Execute(const std::shared_ptr& event) { #endif auto run_number = event->GetRunNumber(); - std::call_once(m_is_initialized, &JMultifactory::Init, this); + try { + std::call_once(m_is_initialized, &JMultifactory::Init, this); + } + catch(std::exception &e) { + // Rethrow as a JException so that we can add context information + throw JException(e.what()); + } + if (m_last_run_number == -1) { // This is the very first run - BeginRun(event); + try { + BeginRun(event); + } + catch(std::exception &e) { + // Rethrow as a JException so that we can add context information + throw JException(e.what()); + } m_last_run_number = run_number; } else if (m_last_run_number != run_number) { // This is a later run, and it has changed - EndRun(); - BeginRun(event); + try { + EndRun(); + } + catch(std::exception &e) { + // Rethrow as a JException so that we can add context information + throw JException(e.what()); + } + try { + BeginRun(event); + } + catch(std::exception &e) { + // Rethrow as a JException so that we can add context information + throw JException(e.what()); + } m_last_run_number = run_number; } - Process(event); + try { + Process(event); + } + catch(std::exception &e) { + // Rethrow as a JException so that we can add context information + throw JException(e.what()); + } } void JMultifactory::Release() { - std::call_once(m_is_finished, &JMultifactory::Finish, this); + try { + std::call_once(m_is_finished, &JMultifactory::Finish, this); + } + catch(std::exception &e) { + // Rethrow as a JException so that we can add context information + throw JException(e.what()); + } } JFactorySet* JMultifactory::GetHelpers() {