
Emil Dotchevski wrote:
On Tue, Nov 25, 2008 at 7:41 AM, Chris Newbold <Chris.Newbold@mathworks.com> 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