Boost logo

Boost Users :

Subject: Re: [Boost-users] exception: use of error_info can mask real exceptions
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-05-25 01:29:29


On Sun, May 24, 2009 at 10:09 PM, Andrew Venikov
<andrew.venikov_at_[hidden]> wrote:
> Emil Dotchevski wrote:
>
> <...>
>>
>> That's my point, you want some exceptions emitted by the throw
>> expression to be ignored, and some not.   <..>
>
> I would rather say that the main exception should be thrown no matter
> what.

If you write:

throw foo() << info1(bar());

and bar() throws something (note, this function might have nothing to
do with Boost Exception or foo), do you want that exception silently
ignored?

> When I write this:
>
> throw WidgetAllocError();
>
> It's pretty obvious what I want.
> Of course, it would be nice to have more informative description, that's
> why I would normally add:
>
> throw WidgetAllocError() << WidgetErrorDescription(strWidgetName);
>
> But this now changes the original intent. By the time we reach the throw
> statement, we've made a decision that an error condition has been
> reached and we want to indicate that error. If we continue propagating
> WidgetAllocError(), then we'll at least know what kind of error
> happened, albeit without extra information.

That "albeit" is very important. It effectively requires the catch
site to be able to deal with a WidgetAllocError that has no additional
information in it. Are you sure you want to impose this requirement on
all programs wrt all exceptions?

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