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 00:23:00


On Sun, May 24, 2009 at 5:11 PM, Andrew Venikov
<andrew.venikov_at_[hidden]> wrote:
>
> <...>
>>
>> What you want is, once you've reached a point in the program that is
>> going to throw an exception, to guarantee that you will throw that
>> exception and not something else.
>
> Precisely.
>
>>
>> The problem is that this has to extend to all failures that can occur
>> within the throw expression. Such failures are not limited to
>> bad_alloc; any function you call in the throw expression may throw any
>> exception. I'm reasonably certain that you don't want those to be
>> ignored, do you?
>
> No, I wouldn't want those to be ignored.

That's my point, you want some exceptions emitted by the throw
expression to be ignored, and some not. Even if that was a good idea,
you have to come up with an intuitive criteria which isn't going to
surprise other users.

> 1.The system runs out of memory trying to allocate a certain resource.
> 2.An exception that indicates the condition and resource is thrown.
> 3.We try to add a description to the exception thrown, description
>  requires memory.
> 4. But, since we're already out of memory, we fail creating the error
>   description.
>
> What exception would you rather want to receive in this case?

In my mind, the postcondition of throw foo() << info1(...) <<
info2(...) is that a foo exception containing info1 and info2 is
thrown. If that postcondition can not be satisfied, I do want
(another) exception that tells me why.

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