when assertions fail throw an exception instead of aborting

v1
Brett 2024-08-03 19:50:26 -04:00
parent 6acbc24245
commit e979447de0
3 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake)
set(BLT_VERSION 0.18.17)
set(BLT_VERSION 0.18.18)
set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT)

View File

@ -35,7 +35,6 @@ namespace blt
#define BLT_ASSERT(expr) do { \
if (!static_cast<bool>(expr)) { \
blt::b_assert_failed(#expr, nullptr, __FILE__, __LINE__); \
std::exit(EXIT_FAILURE); \
} \
} while (0)
@ -46,7 +45,6 @@ namespace blt
#define BLT_ASSERT_MSG(expr, fail_message) do { \
if (!static_cast<bool>(expr)) { \
blt::b_assert_failed(#expr, fail_message, __FILE__, __LINE__); \
std::exit(EXIT_FAILURE); \
} \
} while (0)

View File

@ -89,11 +89,15 @@ namespace blt {
printStacktrace(messages, size, path, line);
BLT_FREE_STACK_TRACE();
#endif
#else
(void) expression;
(void) msg;
(void) path;
(void) line;
#endif
if (msg != nullptr)
throw abort_exception(msg);
throw abort_exception(expression);
}
void printStacktrace(char** messages, int size, const char* path, int line)