diff --git a/CMakeLists.txt b/CMakeLists.txt index a915f7c..9f53061 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 0.18.15) +set(BLT_VERSION 0.18.16) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/std/assert.h b/include/blt/std/assert.h index a49313b..0c6f4ef 100644 --- a/include/blt/std/assert.h +++ b/include/blt/std/assert.h @@ -18,23 +18,6 @@ namespace blt void b_throw(const char* what, const char* path, int line); void b_abort(const char* what, const char* path, int line); - - struct abort_exception : public std::exception - { - public: - abort_exception() = default; - - explicit abort_exception(std::string error): error(std::move(error)) - {} - - [[nodiscard]] const char* what() const noexcept override - { - return error.c_str(); - } - - private: - std::string error; - }; } /** @@ -73,6 +56,6 @@ namespace blt #define BLT_THROW(throwable) do {blt::b_throw(throwable.what(), __FILE__, __LINE__); throw throwable;} while(0) -#define BLT_ABORT(message) do {blt::b_abort(message, __FILE__, __LINE__); throw blt::abort_exception(); } while (0) +#define BLT_ABORT(message) do {blt::b_abort(message, __FILE__, __LINE__); std::abort(); } while (0) #endif //BLT_ASSERT_H diff --git a/src/blt/std/assert.cpp b/src/blt/std/assert.cpp index fd615b1..2b596e2 100644 --- a/src/blt/std/assert.cpp +++ b/src/blt/std/assert.cpp @@ -10,6 +10,24 @@ #include #include #include +#include + +struct abort_exception : public std::exception +{ + public: + explicit abort_exception(const char* error): error(error) + {} + + [[nodiscard]] const char* what() const noexcept override + { + if (error == nullptr) + return "Abort called"; + return error; + } + + private: + const char* error{nullptr}; +}; #if defined(__GNUC__) && !defined(__EMSCRIPTEN__) @@ -129,7 +147,7 @@ namespace blt { #if defined(__GNUC__) && !defined(__EMSCRIPTEN__) BLT_STACK_TRACE(50); #endif - BLT_FATAL("----{ABORT}----"); + BLT_FATAL("----{BLT ABORT}----"); BLT_FATAL("\tWhat: %s", what); BLT_FATAL("\tcalled from %s:%d", path, line); #if defined(__GNUC__) && !defined(__EMSCRIPTEN__) @@ -137,7 +155,7 @@ namespace blt { BLT_FREE_STACK_TRACE(); #endif - std::exit(EXIT_FAILURE); + throw abort_exception(what); }