e27eee50 [teagba] Add set and scroll background offset functions fd610454 [nostalgia/gfx] Fix compiler warning e61d4647 [nostalgia/gfx] Fix BG tilesheet loading, add background offset functions c275c5f5 [hull] Disable building hull for now fbf49ba5 [ox/std] Add pre- and post-increment operators to Span 92f74b27 [ox/std] Add null check for deallocating in consteval context Vector 934f0c92 [ox/std] Add beginsWith and endsWith variants that that cingle chars ee9a3e11 [ox/std] Cleanup 16886cdf [hull] Add start on command interpreter 08b9508d [ox/std] Give std::ignore a named type 69bd968f [nostalgia/player] Fix build 4e7dc666 [nostalgia,olympic] Rename string len() functions to size() bea0cf5a [ox/std] Rename string len() functions to size() git-subtree-dir: deps/nostalgia git-subtree-split: e27eee50f05bb437710313430e0d9cef636a66b1
84 lines
2.3 KiB
C++
84 lines
2.3 KiB
C++
/*
|
|
* Copyright 2015 - 2025 gary@drinkingtea.net
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "fmt.hpp"
|
|
#include "realstd.hpp"
|
|
#include "stacktrace.hpp"
|
|
#include "trace.hpp"
|
|
|
|
#include "assert.hpp"
|
|
|
|
namespace ox {
|
|
|
|
void panic(StringViewCR file, int const line, StringViewCR panicMsg, Error const&err) noexcept {
|
|
oxErrf("\033[31;1;1mPANIC:\033[0m [{}:{}]: {}\n", file, line, panicMsg);
|
|
if (err.msg) {
|
|
oxErrf("\tError Message:\t{}\n", err.msg);
|
|
}
|
|
oxErrf("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
|
|
if (err.src.file_name() != nullptr) {
|
|
oxErrf("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line());
|
|
}
|
|
#ifdef OX_USE_STDLIB
|
|
printStackTrace(2);
|
|
oxTrace("panic").del("") << "Panic: " << panicMsg << " (" << file << ":" << line << ")";
|
|
std::abort();
|
|
#else
|
|
while (1);
|
|
#endif
|
|
}
|
|
|
|
#if __GNUC__
|
|
__attribute__((weak))
|
|
#endif
|
|
void panic(const char *file, int const line, char const*panicMsg, Error const&err) noexcept {
|
|
panic(StringView{file}, line, StringView{panicMsg}, err);
|
|
}
|
|
|
|
void assertFailFuncRuntime(
|
|
StringViewCR file,
|
|
int const line,
|
|
StringViewCR assertTxt,
|
|
StringViewCR msg) noexcept {
|
|
#ifdef OX_USE_STDLIB
|
|
auto const st = genStackTrace(2);
|
|
oxTracef("assert", "Failed assert: {} ({}) [{}:{}]:\n{}", msg, assertTxt, file, line, st);
|
|
abort();
|
|
#else
|
|
oxErrf("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, msg);
|
|
oxTracef("assert", "Failed assert: {} ({}) [{}:{}]", msg, assertTxt, file, line);
|
|
constexprPanic(file, line, msg);
|
|
#endif
|
|
}
|
|
|
|
void assertFailFuncRuntime(
|
|
StringViewCR file,
|
|
int const line,
|
|
[[maybe_unused]] Error const&err,
|
|
StringViewCR,
|
|
StringViewCR assertMsg) noexcept {
|
|
#if defined(OX_USE_STDLIB)
|
|
auto msg = sfmt("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, assertMsg);
|
|
if (err.msg) {
|
|
msg += sfmt("\tError Message:\t{}\n", err.msg);
|
|
}
|
|
msg += sfmt("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
|
|
if (err.src.file_name() != nullptr) {
|
|
msg += sfmt("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line());
|
|
}
|
|
msg += genStackTrace(2);
|
|
oxErr(msg);
|
|
oxTracef("assert", "Failed assert: {} [{}:{}]", assertMsg, file, line);
|
|
abort();
|
|
#else
|
|
constexprPanic(file, line, assertMsg);
|
|
#endif
|
|
}
|
|
|
|
}
|