Boost logo

Boost :

Subject: Re: [boost] Support for std::nested_exception in Boost.Exception?
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-11-25 19:25:40


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() );

or, actually:

    BOOST_THROW_WITH_CONTEXT( translated() );

> }

Under C++03 we need to be careful to not call current_exception() when an
exception isn't active, so we can't just automatically fold this into the
boost::exception constructor or the existing macro.

--
Peter Dimov
http://www.pdplayer.com

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