An exception backtracing library
MIT License
This library uses
std::nested_exception
and
std::throw_with_nested
and can be applied in order to not lose information while propagating an original
std::exception
upwards through a chain of function calls and create a backtrace without any
overhead (compare e.g. logging of debug messages). This avoids much of the need for any
debugging and provides a way of ensuring that a library does not crash ungracefully.
#include <trace/trace.hpp>
The library revolves around three macros
trace::initiate
: can be placed anywhere. Takes a std::string message
and initiatestrace::propagate
: should be placed in a catch-block. Takes a std::string message
,trace::handle
: should be placed in a catch-block. Takes a std::exception &
andand the function trace::latest()
, which returns the most recent backtrace, created by
the call to handle
.