How to properly catch std and boost exceptions
std::exception
has a member function called what()
that returns a const char*
that might explain what happened. If you want to log it (guessing that LOG_FATAL
wraps printf
somehow) you can do:
catch(std::exception const& ex)
{
LOG_FATAL("Can't init settings. %s", ex.what());
}
For boost::exception
though you can use boost::get_error_info
to find out more about it.
probably WAY too late in answering... but
<...snip...>
catch (const boost::exception& e)
{
std::string diag = diagnostic_information(e);
// display your error message here, then do whatever you need to, e.g.
LOG_FATAL("Can't init settings. %s", diag);
}
<...snip...>