abort correctiono
parent
c3fdfbade6
commit
fb17ff16c0
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,6 +10,24 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue