From 11e75cb6caa370a66b851dc43aeddbe649e1b089 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 28 Jan 2026 00:46:55 -0600 Subject: [PATCH] [ox/std] Add Error::reoriginate --- deps/ox/src/ox/std/error.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 18269314..ef0d7bbe 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -37,7 +37,7 @@ using ErrorCode = uint16_t; struct [[nodiscard]] Error { std::source_location src; - ox::CString msg = nullptr; + CString msg = nullptr; ErrorCode errCode = 0; constexpr Error() noexcept = default; @@ -51,7 +51,7 @@ struct [[nodiscard]] Error { explicit constexpr Error( ErrorCode const errCode, - ox::CString msg, + CString const msg, std::source_location const &src = std::source_location::current()) noexcept: src{src}, msg{msg}, @@ -62,6 +62,18 @@ struct [[nodiscard]] Error { return errCode; } + constexpr Error reoriginate( + ErrorCode const pErrCode, + CString const pMsg = nullptr, + std::source_location const &pSrc = std::source_location::current()) const noexcept { + return Error{pErrCode, pMsg, pSrc}; + } + + constexpr Error reoriginate( + std::source_location const &pSrc = std::source_location::current()) const noexcept { + return Error{errCode, msg, pSrc}; + } + }; [[nodiscard]] @@ -112,13 +124,13 @@ struct Exception: public std::exception { [[noreturn]] void panic( Error const &err, - char const *panicMsg, + CString panicMsg, std::source_location const &src = std::source_location::current()) noexcept; template struct [[nodiscard]] Result { - using type = typename remove_reference::type; + using type = remove_reference_t; T value; Error error;