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
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:
Internal Evaluation Errors.
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 list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk