Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2022-02-07 08:49:32


On 2/7/22 10:57, Emil Dotchevski via Boost wrote:
>> I would like to ask to not do this, as this is a breaking change and I
>> have written code (outside Boost) that relies on BOOST_THROW_EXCEPTION
>> and boost::exception. That is, I expect that an exception thrown by
>> BOOST_THROW_EXCEPTION triggers `catch (boost::exception& e)` handler,
>> where I may augment it with additional info before rethrowing.
>
> By the way you can use Boost LEAF for this, it's more convenient and more
> efficient. Instead of:
>
> typedef boost::error_info<struct my_info_, int> my_info;
>
> void f()
> {
> try
> {
> g();
> }
> catch( boost::exception & e )
> {
> e << my_info(42);
> throw;
> }
> }
>
> You'd use:
>
> struct my_info { int value };
>
> void f()
> {
> auto load = on_error( my_info{42} );
> g();
> }
>
> The above generally works with any exception, there is no need to derive
> from a special base type.

Thanks, but that introduces a new info passing mechanism (i.e. part of
the data is passed with the exception and part is passed in Boost.LEAF).
I'd rather keep everything contained in the exception.

BTW, does Boost.LEAF work for passing error states across shared library
boundaries?


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