Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2007-08-13 17:35:08


Author: pbristow
Date: 2007-08-13 17:35:07 EDT (Mon, 13 Aug 2007)
New Revision: 38631
URL: http://svn.boost.org/trac/boost/changeset/38631

Log:
Update for policies

Text files modified:
   sandbox/math_toolkit/libs/math/doc/distributions/error_handling_example.qbk | 64 +++++----------------------------------
   1 files changed, 9 insertions(+), 55 deletions(-)

Modified: sandbox/math_toolkit/libs/math/doc/distributions/error_handling_example.qbk
==============================================================================
--- sandbox/math_toolkit/libs/math/doc/distributions/error_handling_example.qbk (original)
+++ sandbox/math_toolkit/libs/math/doc/distributions/error_handling_example.qbk 2007-08-13 17:35:07 EDT (Mon, 13 Aug 2007)
@@ -1,65 +1,19 @@
 [section:error_eg Error Handling Example]
 
-TODO: this documentation is out of date, rewrite it!!
-
 See [link math_toolkit.special.error_handling error handling]
 for a detailed explanation of the mechanism of handling errors,
-including the common "bad" arguments to distributions and functions.
-
-But, by default, *none of these exceptions will be raised*,
-and the most appropriate value, usually a NaN, or zero, will be returned.
-So, for example, without any attempt to deal with errors, if we write
-
- cout << "Probability of Student's t is "
- << boost::math::cdf(students_t(-1), -1) << endl;
-
-the output will be:
-
- Probability of Student's t is 1.#QNAN
-
-However, macros control whether an exception is raised, or not,
-for the following errors:
-
- BOOST_MATH_THROW_ON_DOMAIN_ERROR
- BOOST_MATH_THROW_ON_OVERFLOW_ERROR
- BOOST_MATH_THROW_ON_OVERFLOW_ERROR
- BOOST_MATH_THROW_ON_UNDERFLOW_ERROR
- BOOST_MATH_THROW_ON_DENORM_ERROR
- BOOST_MATH_THROW_ON_LOGIC_ERROR
+including the common "bad" arguments to distributions and functions,
+and how to use __policy_section to control it.
 
-[important These #defines *MUST* be *BEFORE* the function or distribution #include!]
+But, by default, *exceptions will be raised*,
+to get the most appropriate value, usually a NaN, or zero, returned you need to change the policy.
 
-If defined, for example with
+See [@../../example/error_handling_example.cpp error_handling_example.cpp] for the source code of an example.
 
- #define BOOST_MATH_THROW_ON_DOMAIN_ERROR
-
-before
-
- #include <boost/math/distributions/students_t.hpp>
-
-then a domain_error exception will throw if we write
-
- try
- {
- cout << "Probability of Student's t is "
- << boost::math::cdf(students_t(-1), -1) << endl; // Bad arguments!
- }
- catch(const std::exception& e)
- {
- std::cout <<
- "\n""Message from thrown exception was:\n " << e.what() << std::endl;
- }
-
-and will output:
-
- Message from thrown exception was:
- Error in function __thiscall
- boost::math::students_t_distribution<double>::students_t_distribution(double):
- Degrees of freedom argument is -1, but must be > 0 !
-
-See [@../../example/error_handling_example.cpp error_handling_example.cpp]
+This example is detailed at the Policy tutorial in
+[link math_toolkit.policy.pol_tutorial.changing_policy_defaults Changing the Policy Defaults].
 
-[caution If you enable throw but do NOT have try & catch block,
+[caution If throw is enabled (the default) but do NOT have try & catch block,
 then the program will terminate with an uncaught exception and probably abort.
 Therefore to get the benefit of helpful error messages, enabling *all exceptions
 and using try & catch* is recommended for all applications.
@@ -67,7 +21,7 @@
   
 [endsect] [/section:error_eg Error Handling Example]
 [/
- Copyright 2006 John Maddock and Paul A. Bristow.
+ Copyright 2007 John Maddock and Paul A. Bristow.
   Distributed under the Boost Software License, Version 1.0.
   (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk