OPM/opm-common

ErrorGuard::~ErrorGuard should not terminate program

blattms opened this issue · 2 comments

It calls std::exit(1) if there are recorded warnings. Seems a surprising and IMHO unclean. Any particular reason for that?

bska commented

It calls std::exit(1) if there are recorded warnings.

Kind of. The call to exit is if there are recorded errors and their "action" is configured to be EXIT1 or DELAYED_EXIT1. This is supposed to happen only for very serious problems in the input which mean we're unable to continue the run. In an MPI run there should probably be a different mechanism to achieve the same result, but we can't pretend the situation doesn't exist.

I don't think you need MPI to get into an awkward situation. We just need to throw an exception while the ErrorGuard with recorded errors is on the stack and that gets unwinded due to the exception.