Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2022-02-07 07:57:00


> I would like to ask to not do this, as this is a breaking change and I
> have written code (outside Boost) that relies on BOOST_THROW_EXCEPTION
> and boost::exception. That is, I expect that an exception thrown by
> BOOST_THROW_EXCEPTION triggers `catch (boost::exception& e)` handler,
> where I may augment it with additional info before rethrowing.

By the way you can use Boost LEAF for this, it's more convenient and more
efficient. Instead of:

typedef boost::error_info<struct my_info_, int> my_info;

void f()
{
  try
  {
    g();
  }
  catch( boost::exception & e )
  {
    e << my_info(42);
    throw;
  }
}

You'd use:

struct my_info { int value };

void f()
{
  auto load = on_error( my_info{42} );
  g();
}

The above generally works with any exception, there is no need to derive
from a special base type.


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