Skip to content

Commit

Permalink
Fix uncaught C++ exception in runAmiciSimulation (#2338)
Browse files Browse the repository at this point in the history
Previously, an exception during `ReturnData::processSimulationObjects` would result in program termination.

Fixes #1882.
  • Loading branch information
dweindl authored Mar 4, 2024
1 parent 61d17fa commit 3a6b0df
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/amici.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,20 @@ std::unique_ptr<ReturnData> runAmiciSimulation(
);
}

rdata->processSimulationObjects(
preeq.get(), fwd.get(), bwd_success ? bwd.get() : nullptr, posteq.get(),
model, solver, edata
);
try {
rdata->processSimulationObjects(
preeq.get(), fwd.get(), bwd_success ? bwd.get() : nullptr, posteq.get(),
model, solver, edata
);
} catch (std::exception const& ex) {
rdata->status = AMICI_ERROR;
if (rethrow)
throw;
logger.log(
LogSeverity::error, "OTHER", "AMICI simulation failed: %s",
ex.what()
);
}

rdata->cpu_time_total = cpu_timer.elapsed_milliseconds();

Expand Down

0 comments on commit 3a6b0df

Please sign in to comment.