Boost logo

Boost :

Subject: Re: [boost] Boost and exceptions
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-06-23 18:33:19


Dave Abrahams wrote:
> on Sat Jun 23 2012, "Robert Ramey" <ramey-AT-rrsd.com> wrote:
>
>> If you really like boost::exception your code when you eventually can
>> eventually rethrow
>>
>> catch (std::exception & e){ // not additon of &
>> BOOST_THROW_EXCEPTION(e)
>> }
>
> IIUC, even if you change it to catch by reference, as you should, and
> even if std::exception weren't an abstract base class, which it is,
> that approach will slice the caught exception and lose all the
> information thrown with it. BOOST_EXCEPTION_THROW_EXCEPTION needs to
> copy the exception object into this type it builds with multiple
> inheritance from boost::exception, and it needs to do this with full
> knowledge of the static type of the exception being thrown.

wow I overlooked this.

So in our case, if e was reference to an instance of a
boost::archive::archive_exception object
which holds all the interesting data, this information would be thrown away
along
with the actual type of the exception? That's terrible.

Robert Ramey


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