Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2008-01-14 11:45:24


Hi folks I'd like some user feedback on an error-handling design issue if
you're all willing :-)

To the Sandbox "development" version of Boost.Math I've recently added
equivalent functionality to the C99 round/trunc/modf functions: these
convert floating point values to integers or to integer and fractional
parts. However, there are two possible error conditions:

1) The input value is not a number (NaN).
2) The input value is outside the range of the integer type.

We could handle these using the existing error handlers for domain_error's
and overflow_error's respectively, but there's a problem:

Users may legitimately turn off the throwing of exceptions from domain or
overflow errors and prefer the functions to return NaN's and infinities
instead. But this clearly wouldn't make as much sense for these particular
conversion functions given that integers don't support either of these
states....

So I'm tempted to add another error handler specific for integer conversion
failures: the question then is whether this is starting down a slippery
slope to too many error types making the library too hard to understand/use.
Currently we already have:

Pole Errors.
Domain Errors.
Overflow Errors.
Underflow Errors.
Denorm Errors.
Internal Evaluation Errors.

See
http://svn.boost.org/svn/boost/trunk/libs/math/doc/sf_and_dist/html/math_toolkit/main_overview/error_handling.html
for the details.

So am I going overboard with error types, or worrying about nothing?

Thanks for any thoughts/user experience you may have,

Regards, John Maddock.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net