Boost logo

Boost :

Subject: Re: [boost] [outcome] Exception safety guarantees
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2017-05-28 23:34:54


On Sat, May 27, 2017 at 9:35 AM, Andrzej Krzemienski via Boost <
boost_at_[hidden]> wrote:

> But whatever the answer, we are arriving at the "nested failure" problem:
> we are processing a (potential) failure report, and this processing fails.
> What should we do? report the new error condition and ignore the previous?
>

You should always report the immediate failure not the failure you failed
to report, because this is a different failure that may require a different
handler.

Practically speaking what could go wrong when trying to report an error is
that you might run out of memory. So you must be able to report out of
memory conditions without running out of memory. This is also how C++
exception handling works, in general throwing an exception may require
memory allocation (not necessarily from the heap) which may fail, in which
case std::bad_alloc will be thrown instead.

This also trivially follows from RAII. It's good to know that the objects
you are working with are good and complete, and exceptions or other objects
that communicate failures are no exception.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk