Skip to content

Commit

Permalink
JMultifactory catches std::exception and rethrows as a JException
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Nov 21, 2023
1 parent 20a6276 commit 5ae2275
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions src/libraries/JANA/JMultifactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,60 @@ void JMultifactory::Execute(const std::shared_ptr<const JEvent>& 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() {
Expand Down

0 comments on commit 5ae2275

Please sign in to comment.