[ox/std] Add ValErr support to oxReturnError
This commit is contained in:
parent
98d045827e
commit
5834201fbb
15
deps/ox/src/ox/std/error.hpp
vendored
15
deps/ox/src/ox/std/error.hpp
vendored
@ -17,7 +17,7 @@
|
||||
#define OxError(x) static_cast<ox::Error>(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<typename T>
|
||||
[[nodiscard]] constexpr ox::Error toError(ox::ValErr<T> ve) noexcept {
|
||||
return ve.error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user