Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-03-20 00:31:02

Let me suggest the following idiom as a reasonable way to report
fatal runtime errors:

   template <typename X>
      void error(const X& x) throw() {
         throw x;

Yes, it looks silly. But it will force a call to unexpected(),
which by default will terminate(), and the client can replace
the default behavior via the standard set_unexpected() facility.

What the client cannot do is contrive to keep running despite
the error, so it is not appropriate for those who a prefer a
"damn the torpedoes, full speed ahead" style of error handling.

Well, I suppose the truly determined client can always do

   #define error(x) (throw(x))

and recompile. Or, at the risk of undefined behavior, one could
install an unexpected_handler that does a longjmp(), which might
even be appropriate in some environments.

From: Beman Dawes <bdawes_at_[hidden]>
> ...
> While a configurable assert sounds intriguing, it may turn out to be much
> further off that one might think. Lots of good programmers have tried to
> come up with a better assert, only to have their creations fall by the
> wayside.
> That isn't to say others shouldn't keep trying, but until they succeed just
> stick with assert() or throwing an exception, using the guidelines from
> Dave Abrahams and others as to when to do which.
> --Beman
> PS: If someone does come up with a configurable assert(), it probably
> should avoid a name that includes "assert" or "ASSERT". People will just
> assume it is yet another assert() replacement and make all sorts of
> incorrect assumptions about it.

Boost list run by bdawes at, gregod at, cpdaniel at, john at