Boost logo

Boost :

From: Thomas Wenisch (twenisch_at_[hidden])
Date: 2002-07-02 11:20:59


Hello Robert, all,

KA> 2. archive_exception should really be derived from std::exception
 
RR> I considered this and saw no benefit to doing so. How would this be
RR> an improvement?

KA> I really do not want to have more than one catch block for reporting
KA> errors, one for archive_exception, one for std::exception, one for
KA> something else. Nor do I want to remember that some exceptions should
KA> be catched in a different way.
KA> Therefore, _all_ possible exceptions should be derived from
KA> std::exception and provide meaningful result on what(). Note that you
KA> will not find any exception in boost that violates these rules.

RR> I believe the most general way to address this situation is to use:
RR> catch(...)

I think the added benefit Kostya is looking for with std::exception is the
"meaningful result on what()". Most if not all exceptions thrown by Boost
libraries provide some kind of helpful debug output when what() is
called. If we use catch(...) as you suggest, then we either have to
have two catch clauses (the exact code duplication we want to avoid) or we
just use catch(...) and lose the useful debug information from what().

Even if you do not override what() to provide useful information, it will
save users the trouble of adding catch(...) everywhere that they
already have catch(std::exception) when using your library.

What disadvantage do you see to deriving from std::exception?

Regards,
-Tom Wenisch
Computer Architecture Lab
Carnegie Mellon University


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk