diff --git a/luna/Result.h b/luna/Result.h index 1aec130f..13dfd58a 100644 --- a/luna/Result.h +++ b/luna/Result.h @@ -2,6 +2,7 @@ #include #include #include +#include #include struct Error @@ -92,6 +93,12 @@ template class Result return {m_error}; } + const char* error_string() + { + check(has_error()); + return ::error_string(m_error); + } + T value() { check(has_value()); @@ -224,6 +231,12 @@ template <> class Result return {m_error}; } + const char* error_string() + { + check(has_error()); + return ::error_string(m_error); + } + void value() { check(has_value()); @@ -242,7 +255,7 @@ template <> class Result }; // clang-format off -#define err Error{0} +#define err(x) Error{x} // clang-format on #define TRY(expr) \