Brian Silverman | 32ed54e | 2018-08-04 23:37:28 -0700 | [diff] [blame^] | 1 | [section:error_eg Error Handling Example] |
| 2 | |
| 3 | See [link math_toolkit.error_handling error handling documentation] |
| 4 | for a detailed explanation of the mechanism of handling errors, |
| 5 | including the common "bad" arguments to distributions and functions, |
| 6 | and how to use __policy_section to control it. |
| 7 | |
| 8 | But, by default, *exceptions will be raised*, for domain errors, |
| 9 | pole errors, numeric overflow, and internal evaluation errors. |
| 10 | To avoid the exceptions from getting thrown and instead get |
| 11 | an appropriate value returned, usually a NaN (domain errors |
| 12 | pole errors or internal errors), or infinity (from overflow), |
| 13 | you need to change the policy. |
| 14 | |
| 15 | [import ../../example/error_handling_example.cpp] |
| 16 | |
| 17 | [error_handling_example] |
| 18 | |
| 19 | [caution If throwing of exceptions is enabled (the default) but |
| 20 | you do *not* have try & catch block, |
| 21 | then the program will terminate with an uncaught exception and probably abort. |
| 22 | |
| 23 | Therefore to get the benefit of helpful error messages, enabling *all exceptions |
| 24 | and using try & catch* is recommended for most applications. |
| 25 | |
| 26 | However, for simplicity, the is not done for most examples.] |
| 27 | |
| 28 | [endsect] [/section:error_eg Error Handling Example] |
| 29 | [/ |
| 30 | Copyright 2007 John Maddock and Paul A. Bristow. |
| 31 | Distributed under the Boost Software License, Version 1.0. |
| 32 | (See accompanying file LICENSE_1_0.txt or copy at |
| 33 | http://www.boost.org/LICENSE_1_0.txt). |
| 34 | ] |
| 35 | |