Boost logo

Boost :

Subject: Re: [boost] Noexcept
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2017-06-14 19:44:24


On Wed, Jun 14, 2017 at 1:57 AM, Andrzej Krzemienski via Boost <
boost_at_[hidden]> wrote:

> > I think it's not cumbersome at all. Just like when using exceptions, with
> > Noexcept the ability to catch_, do_some_work then throw_ is an important
> > feature. Consider that in general in this context you might not have the
> > slightest idea what errors may pass through it; so you'd:
> >
> > if( auto tr=try_(....) ) {
> > //ok good, do work then return a "good" value
> > } else {
> > log(BOOST_DIAGNOSTIC_INFORMATION(*tr.catch_<>()));
> > return throw_();
> > }
> >
> > Except it won't work, you've uncovered an omission in the Noexcept API.
> The
> > problem is that catch_<> will flag the error as handled, and in this case
> > you don't want that. I need to add another function similar to catch_<>
> > which only gets the error without handling it. Not sure what to call it,
> or
> > maybe instead I can add a member function tr.throw_() which flags the
> error
> > as unhandled.
>
> Yes. this would make Noexcept superior to C++ exceptions in this aspect:
> this would allow to easily identify when you are handling the exception and
> when you are just modifying the exception. Call it "augment"?
>

Not superior, "closely mimicking" :) Using exception handling you can

catch(...)
{
  do_something();
  throw; //the original object continues up the stack
}

Boost Exception is all about augmenting exceptions with relevant data in
error-neutral contexts. Also there is this:
http://pdimov.com/cpp2/P0640R0.pdf


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