diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index 741d27f1..e2713cc3 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -32,18 +32,22 @@ void assertFunc([[maybe_unused]]const char *file, [[maybe_unused]]int line } template<> -void assertFunc([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg) { -#if defined(OX_USE_STDLIB) +void assertFunc(const char *file, int line, Error err, const char *msg) { if (err) { - auto ei = ErrorInfo(err); - std::cerr << "\033[31;1;1mASSERT FAILURE:\033[0m (" << file << ':' << line << "): " << msg << '\n'; - std::cerr << "\tError Code:\t" << ei.errCode << '\n'; - if (ei.file != nullptr) { - std::cerr << "\tError Location:\t" << reinterpret_cast(ei.file) << ':' << ei.line << '\n'; - } - printStackTrace(2); - std::abort(); + panic(file, line, err, msg); } +} + +void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg) { +#if defined(OX_USE_STDLIB) + std::cerr << "\033[31;1;1mPANIC:\033[0m (" << file << ':' << line << "): " << msg << '\n'; + std::cerr << "\tError Code:\t" << err << '\n'; + if (err.file != nullptr) { + std::cerr << "\tError Location:\t" << reinterpret_cast(err.file) << ':' << err.line << '\n'; + } + printStackTrace(2); + oxTrace("assert").del("") << "Failed assert: " << msg << " (" << file << ":" << line << ")"; + std::abort(); #endif } diff --git a/deps/ox/src/ox/std/assert.hpp b/deps/ox/src/ox/std/assert.hpp index 31a1cc1b..424bf697 100644 --- a/deps/ox/src/ox/std/assert.hpp +++ b/deps/ox/src/ox/std/assert.hpp @@ -23,10 +23,14 @@ void assertFunc(const char *file, int line, bool pass, const char *msg); template<> void assertFunc(const char *file, int line, Error err, const char*); +void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg); + } #ifndef NDEBUG #define oxAssert(pass, msg) ox::assertFunc(__FILE__, __LINE__, pass, msg) +#define oxPanic(pass, msg) ox::panic(__FILE__, __LINE__, pass, msg) #else #define oxAssert(pass, msg) +#define oxPanic(pass, msg) #endif diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 2baea002..6f157491 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -39,20 +39,6 @@ struct BaseError { using Error = Integer; -struct ErrorInfo { - const char *file = nullptr; - int line = -1; - Error errCode = Error(0); - - ErrorInfo() = default; - - ErrorInfo(Error err) { - this->file = err.file; - this->line = err.line; - this->errCode = err; - } -}; - static constexpr Error _error(const char *file, uint32_t line, Error errCode) { Error err = errCode; err.file = file; diff --git a/deps/ox/src/ox/std/trace.cpp b/deps/ox/src/ox/std/trace.cpp index 8934cc56..4811d167 100644 --- a/deps/ox/src/ox/std/trace.cpp +++ b/deps/ox/src/ox/std/trace.cpp @@ -61,11 +61,10 @@ StdOutStream::~StdOutStream() { void logError(const char *file, int line, Error err) { if (err) { - ErrorInfo ei(err); TraceStream trc(file, line, "ox::error"); - trc << "Error:" << ei.errCode; - if (ei.file != nullptr) { - trc << "(" << reinterpret_cast(ei.file) << ":" << ei.line << ")"; + trc << "Error:" << err; + if (err.file != nullptr) { + trc << "(" << reinterpret_cast(err.file) << ":" << err.line << ")"; } } }