Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2020-06-04 22:10:20


Emil Dotchevski wrote:

> I remember when Boost Exception was discussed (ancient history now), David
> Abrahams pointed out that it is unfortunate that it requires an exception
> to be caught before it can be augmented. In terms of Boost Exception, you
> must say:
>
> try
> {
> f();
> }
> catch( boost::exception & e )
> {
> e << more_info{};
> throw;
> }
>
> He thought that we're not really doing error handling here, so the
> addition of more_info should happen automatically. Unfortunately there is
> no good way to do this with Boost Exception. In that design, you need to
> interact with the exception object and the only way to get a reference to
> it is to catch it.

I kind of suspect it will be possible. We could preload the more_info{},
a-la LEAF, and then move that into the active exception "record" on
destruction, if that record is kept outside the exception object, but in a
side storage like a thread-local map.

Sort of a LEAF/Boost.Exception hybrid, where the boost::exception base only
contains the error_id like in LEAF, and the actual error_info is in the map.

The `preload` will need to allocate, but the destructor won't, which seems
enough for our purposes.


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