Boost logo

Boost :

Subject: Re: [boost] Boost and exceptions
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2012-06-24 02:17:03


On Sat, Jun 23, 2012 at 4:19 PM, Robert Ramey <ramey_at_[hidden]> wrote:

> Emil Dotchevski wrote:
> > On Sat, Jun 23, 2012 at 12:11 PM, Robert Ramey <ramey_at_[hidden]> wrote:
>
> > For example, if Boost Serialization calls boost::throw_exception, an
> > application that serializes data that comes from a web site could
> > store the web address, the user name, port number, or whatever else
> > the application needs to handle the exception.
>
> the serialization libary will likely not have this information. Geneally
> the serilalizaiton library uses some sort of stream i/o object. Many
> times errors are detected in the stream. At this point, the none
> of the library knows what the file name is so it can't be added
> in until some way higher level.

That is exactly the problem Boost Exception solves. It allows the user to
augment library exceptions with application-specific information, after
they've been thrown, at a point where the information is naturally
available.

I believe equivalent functionality is available. I believe that boost
> exception
> is more intrusive that it has to be.
>

Here is a typical use of boost::exception (obviously at this time this
won't work for exceptions emitted by Boost Serialization):

catch(boost::exception & e)
{
  e << ip_address(ip) << user_account(u);
  throw;
}

If you can think of a way to provide this functionality less intrusively,
I'm all ears.

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