#include <iostream>
#include "errors/errors.hpp"
error_ptr fn() noexcept
{
};
error_ptr fn2() noexcept
{
auto err = fn();
}
int main()
{
auto err = fn2();
std::cerr << "Error: " << err << std::endl;
auto loc = err->location();
assert(loc.has_value());
std::cerr << "Error function: " << loc->function_name() << std::endl
<< "Error file_name: " << loc->file_name() << std::endl
<< "Error line: " << loc->line() << std::endl
<< "Error column: " << loc->column() << std::endl;
#if defined(ERRORS_ENABLE_NLOHMANN_JSON_SUPPORT)
std::cerr << "Error in JSON:" << std::endl
<< nlohmann::json(err) << std::endl;
#endif
return 0;
}
Smart pointer to errors::error with some utility member functions.
Definition error_ptr.hpp:13
An error that has a message.
Definition runtime_error.hpp:18
A function like class to wrap an error.
Definition wrap.hpp:14