5#include "errors/error_ptr.hpp"
6#include "errors/source_location.hpp"
7#include "nlohmann/json.hpp"
9#if defined(NLOHMANN_JSON_NAMESPACE_BEGIN) && \
10 defined(NLOHMANN_JSON_NAMESPACE_END)
11NLOHMANN_JSON_NAMESPACE_BEGIN
19 static void to_json(::nlohmann::json &j,
20 const ::errors::source_location &loc)
23 j[
"function_name"] = loc.function_name();
24 j[
"line"] = loc.line();
25 j[
"column"] = loc.column();
31 static void to_json(::nlohmann::json &j, const ::errors::error_ptr &err)
39 if (err->location()) {
40 j[
"location"] = err->location().value();
43 j[
"message"] = err->what();
45 j[
"caused_by"] = err->cause();
49#if defined(NLOHMANN_JSON_NAMESPACE_BEGIN) && \
50 defined(NLOHMANN_JSON_NAMESPACE_END)
51NLOHMANN_JSON_NAMESPACE_END
Smart pointer to errors::error with some utility member functions.
Definition error_ptr.hpp:13
The source location.
Definition source_location.hpp:46
constexpr const char * file_name() const noexcept
Returns the file name, or "unsupported" if it is not supported by the compiler.
Definition source_location.hpp:85