From 5834201fbbdff4d0d12df6c02e27f283a3727d5d Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 16 Jun 2019 19:00:47 -0500 Subject: [PATCH] [ox/std] Add ValErr support to oxReturnError --- deps/ox/src/ox/std/error.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 2380c6e7..31af8820 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -17,7 +17,7 @@ #define OxError(x) static_cast(x) #endif -#define oxReturnError(x) if (const auto _err = x) return _err +#define oxReturnError(x) if (const auto _err = ox::error::toError(x)) return _err namespace ox { @@ -77,5 +77,18 @@ struct ValErr { }; +namespace error { + +[[nodiscard]] constexpr ox::Error toError(ox::Error e) noexcept { + return e; +} + +template +[[nodiscard]] constexpr ox::Error toError(ox::ValErr ve) noexcept { + return ve.error; +} + +} + }