Boost logo

Boost Users :

Subject: Re: [Boost-users] exception: use of error_info can mask real exceptions
From: Rainer Deyke (rainerd_at_[hidden])
Date: 2009-05-25 02:24:10

Andrew Venikov wrote:
> It looks like we really have to decide, what's more important -
> preserving the original exception or preserving a newer exception.
> I'm trying to understand whether this dilemma simply presents a matter
> of taste, or is there a real (if a little academical) problem to solve.
> If I'm convinced that it's just a matter of taste - then I'm fine with
> either way. But so far I feel that importance of receiving the original
> exception outweighs the possible loss of other exceptions (which by the
> way wouldn't be thrown in a first place if it wasn't for the original
> exception)
> Maybe others can chime in.

I think it almost never matters, and it especially doesn't matter when
the second exception is std::bad_alloc. When you run out of memory, you
have to abort the current operation. It doesn't matter if you ran out
of memory before or after another failure occurred.

The difference between exceptions only matters if you can somehow
recover from one exception but not the other. In this case, the more
severe exception - the one from which it is harder to recover - should
have priority. std::bad_alloc is almost always the severest exception
possible because it is almost impossible to reliably recover from it.
Therefore std::bad_alloc should usually have priority.

Rainer Deyke - rainerd_at_[hidden]

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