This commit is contained in:
20
deps/ox/src/ox/std/error.hpp
vendored
20
deps/ox/src/ox/std/error.hpp
vendored
@@ -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<typename T>
|
||||
struct [[nodiscard]] Result {
|
||||
|
||||
using type = typename remove_reference<T>::type;
|
||||
using type = remove_reference_t<T>;
|
||||
|
||||
T value;
|
||||
Error error;
|
||||
|
||||
Reference in New Issue
Block a user