Neither. The right thing to do if something doesn't work is to
throw an exception, then let the first component in which it's
nested that can resolve the exception resolve it. That's why we
have lots of exceptions and exception types, but no error codes
anywhere. The basic pattern in a local context is this:
try {
do update;
} catch (const error_t& e) {
do something else;
}
where error_t is the error you know how to catch and resolve. But
what often happens is that a function just throws and something
non-local cleans up. That's what happens for arithmetic errors in
log prob or gradient evals --- they cause a failure which gets caught
by either the sampling or optimization algorithm.
BUT, if that "something else" is common and not really a "failure",
then you want to use a boolean, because there's no "error" to report
with a code.
- Bob
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-dev+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.