Boost logo

Boost :

Subject: Re: [boost] [exception] Virtual inheritance with no default constructors
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-05-15 12:55:56


On Fri, May 15, 2009 at 7:57 AM, Adam Badura <abadura_at_[hidden]> wrote:
>> On Wed, May 13, 2009 at 11:26 PM, Adam Badura <abadura_at_[hidden]> wrote:
>   If I am not mistaken it shouldn't be hard to allow
> boost::diagnostic_information act on exception_ptr like on ordinary
> exception.

Ah, yes this makes sense. Thanks for the suggestion, I'll add
exception_ptr handling in diagnostic_information.

>   And yes. I know you are against chaining exceptions. However I showed some
> use cases and you haven't showed any other solution to those (which does not
> mean that non exists). Also note that simply copying data from one exception
> to the other will not do as it might override some data (like the basic
> ones: file name, line number and function name).

Well, I didn't want this to turn into an argument for or against
wrapping, but consider a generic context:

void open_file( boost::function<void(char const *)> const & loader,
char const * name )
{
  try
  {
    loader(name);
  }
  catch( ... )
  {
    throw open_file_error(boost::current_exception());
  }
}

Sure, callers of open_file can now catch open_file_error. And then
what? It may contain any exception at all in it. You have the
equivalent of a void pointer: it's only useful if you know its
original type, so you can "cast" it back to it.

How do I deal with this situation *generically*? Obviously, if I have
to deal with it specifically, there's no point in wrapping, I'd simply
catch the original exception.

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