Boost logo

Boost :

Subject: Re: [boost] Support for std::nested_exception in Boost.Exception?
From: Emil Dotchevski (emil_at_[hidden])
Date: 2008-11-25 17:13:54


On Tue, Nov 25, 2008 at 1:58 PM, Sebastian Redl
<sebastian.redl_at_[hidden]> wrote:
> 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.

Depends on what you mean by "reimplemented". The code above uses a
different interface than N2559.

My point was that I don't see why nested exceptions need any special
handling in Boost, provided that boost::exception can transport
anything at all, including exception_ptr if that's what you want.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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