5#include <boost/stacktrace/stacktrace.hpp>
8#include <fmt/ostream.h>
23 boost::stacktrace::stacktrace trace = boost::stacktrace::stacktrace::from_current_exception();
24 std::string except_str = fmt::format(
"Unhandled exception: {}", exception);
25 fmt::println(std::cerr,
"{}", except_str);
26 fmt::println(std::cerr,
"{}", std::string(except_str.size(),
'='));
28 std::string stacktrace_str = fmt::to_string(fmt::streamed(trace));
29 fmt::println(std::cerr,
"Stacktrace:\n{}", stacktrace_str.empty() ?
" <unavailable>" : stacktrace_str);
32template <
typename Func,
typename... Args>
33 requires(std::invocable<Func, Args...>)
34std::optional<std::invoke_result_t<Func, Args...>>
wrap_throwable_fn(Func&& fn, Args&&... args) {
36 return std::invoke(std::forward<Func>(fn), std::forward<Args>(args)...);
37 }
catch (
const std::exception& ex) {
Definition asm_buffer.hpp:19
void trace_exception(const T &exception)
Definition trace_exception.hpp:22
std::optional< std::invoke_result_t< Func, Args... > > wrap_throwable_fn(Func &&fn, Args &&... args)
Definition trace_exception.hpp:34