Boost logo

Boost :

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


On Tue, Nov 25, 2008 at 4:25 PM, Peter Dimov <pdimov_at_[hidden]> wrote:
> When Alisdair asked me to comment on the nested_exception paper, I suggested
> that it needs to be folded into std::exception, providing
>
> std::exception_ptr std::exception::context() const;
>
> that returns the value of std::current_exception() at construction time.
> This was (unfairly - IMHO) rejected for ABI reasons. With that in mind,
>
> Emil Dotchevski:
>>
>> 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));
>
> I'd say that this needs to be:
>
> throw translated() << context( boost::current_exception() );

The problem is that boost::current_exception may not always be able to
get you the correct exception type (so far we only have Antony's
implementation for MSVC which I haven't yet integrated in
boost::exception, and which doesn't work in 64-bit builds AFAIK.)

Certainly, if we're considering some 3rd party library which throws
exceptions using throw directly, boost::current_exception won't do --
you need to catch this and that and use boost::copy_exception.

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