Boost logo

Boost :

Subject: Re: [boost] Support for std::nested_exception in Boost.Exception?
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2008-11-25 16:58:17


Emil Dotchevski wrote:
> On Tue, Nov 25, 2008 at 7:41 AM, Chris Newbold
> <Chris.Newbold_at_[hidden]> wrote:
>
>> Anyway, std::nested_exception looks pretty trivial
>> to implement given the bits that already exist in
>> Boost.Exception. Would you be open to a patch
>> providing an implementation?
>>
>
> What's wrong with
>
> struct whatever { };
> struct translated: boost::exception, std::exception { };
>
> typedef boost::error_info<struct
> tag_nested_exception,boost::exception_ptr> nested_exception;
>
> ....
> catch( whatever & e )
> {
> throw translated() << nested_exception(boost::copy_exception(e));
> }
>
> Elsewhere, instead of N2559 rethrow_nested:
>
> catch( boost::exception & e ) //or catch(translated & e)
> {
> if( boost::shared_ptr<boost::exception_ptr const>
> n=boost::get_error_info<nested_exception>(e) )
> rethrow_exception(*n);
> }
>
You just reimplemented std::nested_exception. After all,
nested_exception is a pretty thin wrapper around the exception_ptr
mechanism.

Sebastian


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