Boost logo

Boost Users :

Subject: Re: [Boost-users] [exception] Using Boost.Exception infrastructure without using boost::exception
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-05-28 21:56:23


On Sat, May 28, 2011 at 6:27 PM, Mostafa <mostafa_working_away_at_[hidden]> wrote:
> Though,
> http://www.boost.org/doc/libs/1_46_1/libs/exception/doc/enable_current_exception.html
> states:
>
> Note: Instead of using the throw keyword directly, it is preferable to call
> boost::throw_exception. This is guaranteed to throw an exception that
> derives from boost::exception and supports the exception_ptr functionality.
>
>
> And it's not very clear what exactly are the requirements for supporting
> exception_ptr functionality if one doesn't derive from boost::exception.

If you want to use the error info or exception_ptr functionality, the
exception being thrown must derive from boost::exception.

If you pass an exception object of type T that doesn't derive from
boost::exception to boost::throw_exception, it copies it into an
object that derives from both boost::exception and T, and throws that
object. Or you can use the BOOST_THROW_EXCEPTION macro which in
addition will store __FILE__ and __LINE__ in the exception object,
giving you more useful boost::diagnostic_information.

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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net