Catch an exception and re-throw as boost exception

130 Views Asked by At

I am trying to use Boost exceptions for the additional metadata that I can attach to exceptions as they bubble up the call stack. But one use case I have encountered but do not know how to handle is: how do I catch a std::exception and wrap that with a boost exception and throw/rethrow the wrapped exception? For example:

try {
    CallFunctionThatThrowsStdException();
} catch(std::exception& ex) {
    MyBoostException bex{ex};
    bex << "Add metadata for this call scenario";
    throw bex;
}

What is a good open source project that uses Boost.Exception to study?

Thanks!

0

There are 0 best solutions below