stan-dev/stan — pull request #531 by syclik (2014-02-03 20:52:52+00:00)
Title: Bugfix/issue 476 more catch and reject

From pull request #480.

*Summary:* Updated `gm/command.hpp` and `base_hamiltonian.hpp` to catch `std::exception` instead of `std::domain_error` and `std::runtime_error`

*Intended Effect:* Catch more general exceptions in order to (a) print more warning messages on errors, and (b) reject rather than terminate for errors arising from boost::math and our own code.

Boost's math lib functions throw `std::domain_error`, `std::overflow_error`, `std::underflow_error`, `boost::math::rounding_error`, `boost::math::evaluation_error`, whereas Stan functions only explicitly throw `std::domain_errror` as far as I know.

`std::domain_error` extends `std::logic_error`, whereas the rest extend `std::runtime_error`. The most specific superclass that includes them all is `std::exception`.

*Side Effects:* With `std::exception`, we catch almost everything, which is not ideal. We'd rather have out of memory errors actually terminate rather than just reject. But the upside is that the worst that will happen is that we'll keep printing out the same warning message after multiple rejections.

*Documentation:* The change is user facing, but it fixes the behavior to be what we've already documented.

*Reviewer Suggestions:* Just about anyone could do this, but the changes are in code Michael wrote.