stan-dev/stan — pull request #480 by bob-carpenter (2014-01-03 21:51:15+00:00)
Title: Bugfix/issue 476 more catch and reject

*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`. `std::domain_error` extends `std::logic_error`, whereas the rest extend `std::runtime_error`, and 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.