...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/exception/diagnostic_information.hpp>
namespace
boost
{
std::string current_exception_diagnostic_information();
}
This function must not be called outside of a catch block.
If the current exception object can be converted to boost::exception or std::exception, this function returns the same string value returned by diagnostic_information for the current exception object. Otherwise, an unspecified non-empty string is returned.
Typical use is to call current_exception_diagnostic_information from a top-level function to output diagnostic information about unhandled exceptions:
int
main()
{
try
{
run_program();
}
catch(
error & e )
{
//handle error
}
catch(
...)
{
std::cerr << "Unhandled exception!" << std::endl <<
boost::current_exception_diagnostic_information();
}
}