Boost logo

Boost :

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


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

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