diff --git a/deps/ox/src/ox/event/signal.hpp b/deps/ox/src/ox/event/signal.hpp index 51e18dea..bb58e7be 100644 --- a/deps/ox/src/ox/event/signal.hpp +++ b/deps/ox/src/ox/event/signal.hpp @@ -215,7 +215,7 @@ Error Signal::emitCheckError(Args... args) const noexcept { } return ox::Error(0); } catch (const ox::Exception &ex) { - return ox::Error(ex.file, ex.line, ex.errCode, ex.msg); + return ox::Error(ex.errCode, ex.msg, ex.src); } } diff --git a/deps/ox/src/ox/logconn/def.hpp b/deps/ox/src/ox/logconn/def.hpp index 2e8627c1..71b4e72d 100644 --- a/deps/ox/src/ox/logconn/def.hpp +++ b/deps/ox/src/ox/logconn/def.hpp @@ -14,7 +14,7 @@ { \ const auto loggerErr = (loggerName).initConn(appName); \ if (loggerErr) { \ - oxErrf("Could not connect to logger: {} ({}:{})\n", toStr(loggerErr), loggerErr.file, loggerErr.line); \ + oxErrf("Could not connect to logger: {} ({}:{})\n", toStr(loggerErr), loggerErr.src.file_name(), loggerErr.src.line()); \ } else { \ ox::trace::setLogger(&(loggerName)); \ } \ diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index 0a8b7f70..94ad5f63 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -20,8 +20,8 @@ void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err) oxErrf("\tError Message:\t{}\n", err.msg); } oxErrf("\tError Code:\t{}\n", static_cast(err)); - if (err.file != nullptr) { - oxErrf("\tError Location:\t{}:{}\n", err.file, err.line); + if (err.src.file_name() != nullptr) { + oxErrf("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line()); } #ifdef OX_USE_STDLIB printStackTrace(2); @@ -56,8 +56,8 @@ void assertFailFuncRuntime(StringViewCR file, int line, [[maybe_unused]] const E msg += sfmt("\tError Message:\t{}\n", err.msg); } msg += sfmt("\tError Code:\t{}\n", static_cast(err)); - if (err.file != nullptr) { - msg += sfmt("\tError Location:\t{}:{}\n", err.file, err.line); + if (err.src.file_name() != nullptr) { + msg += sfmt("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line()); } msg += genStackTrace(2); oxErr(msg); diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index af33e8b5..2e8e65cf 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -36,28 +36,16 @@ using ErrorCode = uint16_t; struct [[nodiscard]] Error { + std::source_location src; ox::CString msg = nullptr; - ox::CString file = nullptr; - uint16_t line = 0; ErrorCode errCode = 0; constexpr Error() noexcept = default; - explicit constexpr Error( - ox::CString file, - uint32_t const line, - ErrorCode const errCode, - ox::CString msg = nullptr) noexcept: - msg{msg}, - file{file}, - line{static_cast(line)}, - errCode{errCode} {} - explicit constexpr Error( ErrorCode const errCode, std::source_location const&src = std::source_location::current()) noexcept: - file{src.file_name()}, - line{static_cast(src.line())}, + src{src}, errCode{errCode} {} @@ -65,9 +53,8 @@ struct [[nodiscard]] Error { ErrorCode const errCode, ox::CString msg, std::source_location const&src = std::source_location::current()) noexcept: + src{src}, msg{msg}, - file{src.file_name()}, - line{static_cast(src.line())}, errCode{errCode} {} @@ -89,42 +76,31 @@ constexpr auto toStr(Error const&err) noexcept { } struct Exception: public std::exception { + std::source_location src; ox::CString msg = nullptr; - ox::CString file = nullptr; - uint16_t line = 0; ErrorCode errCode = 0; - explicit inline Exception(ox::CString file, uint32_t line, ErrorCode errCode, char const*msg = "") noexcept { - this->file = file; - this->line = static_cast(line); - this->msg = msg; - this->errCode = errCode; - } - explicit inline Exception( ErrorCode const errCode, std::source_location const&src = std::source_location::current()) noexcept: - file{src.file_name()}, - line{static_cast(src.line())}, + src{src}, errCode{errCode} {} explicit inline Exception( ErrorCode const errCode, ox::CString msg, std::source_location const&src = std::source_location::current()) noexcept: + src{src}, msg{msg}, - file{src.file_name()}, - line{static_cast(src.line())}, errCode{errCode} {} explicit inline Exception(Error const&err) noexcept: + src{err.src}, msg{err.msg ? err.msg : ""}, - file{err.file}, - line{err.line}, errCode{err.errCode} {} constexpr Error toError() const noexcept { - return Error(file, line, errCode, msg); + return Error(errCode, msg, src); } [[nodiscard]] diff --git a/deps/ox/src/ox/std/trace.hpp b/deps/ox/src/ox/std/trace.hpp index d2050214..ca201e9c 100644 --- a/deps/ox/src/ox/std/trace.hpp +++ b/deps/ox/src/ox/std/trace.hpp @@ -269,8 +269,8 @@ using TraceStream = NullStream; inline void logError(const char *file, int line, const char *fmt, const Error &err) noexcept { if (err) { TraceStream trc(file, line, "ox::error"); - if (err.file != nullptr) { - trc << "Error: (" << err.file << ":" << err.line << "):"; + if (err.src.file_name() != nullptr) { + trc << "Error: (" << err.src.file_name() << ":" << err.src.line() << "):"; } else { trc << "Error:"; } @@ -282,8 +282,8 @@ inline void logError(const char *file, int line, const Error &err) noexcept { if (err) { TraceStream trc(file, line, "ox::error"); trc << "Error:" << err; - if (err.file != nullptr) { - trc << "(" << err.file << ":" << err.line << ")"; + if (err.src.file_name() != nullptr) { + trc << "(" << err.src.file_name() << ":" << err.src.line() << ")"; } } }