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-24 17:51:33

On Sun, May 24, 2009 at 11:46 AM, Andrew Venikov
<andrew.venikov_at_[hidden]> wrote:
>> Consider this slightly modified example:
>> std::string get_descr();
>> ....
>> throw f1exception() << f1_descr(get_descr());
>> Even if operator<< and f1_descr's constructor never throw, in theory
>> you could still get std::bad_alloc instead of f1exception.
> Exactly! That's what I meant in my original post.

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.

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?

Emil Dotchevski
Reverge Studios, Inc.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at