diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index bbc12f5b5..03712209d 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -12,7 +12,15 @@ #include #else namespace std { -class exception {}; +class exception { + public: + virtual ~exception() = default; + + [[nodiscard]] + virtual const char *what() const noexcept { + return ""; + } +}; } #endif @@ -22,6 +30,7 @@ class exception {}; #include "utility.hpp" #define OxError(...) ox::Error(__FILE__, __LINE__, __VA_ARGS__) +#define OxException(...) ox::Error(__FILE__, __LINE__, __VA_ARGS__) namespace ox { @@ -71,12 +80,28 @@ struct Exception: public std::exception { uint16_t line = 0; ErrorCode errCode = 0; + explicit inline Exception(const char *file, uint32_t line, ErrorCode errCode, const char *msg = nullptr) noexcept { + this->file = file; + this->line = line; + this->msg = msg; + this->errCode = errCode; + } + inline explicit Exception(const Error &err) { this->msg = err.msg; this->file = err.file; this->line = err.line; this->errCode = err.errCode; } + + constexpr Error toError() const noexcept { + return Error(file, line, errCode, msg); + } + + [[nodiscard]] + const char *what() const noexcept override { + return msg; + } }; template