diff --git a/src/Exception.hpp b/src/Exception.hpp index e14a7c2..38890de 100644 --- a/src/Exception.hpp +++ b/src/Exception.hpp @@ -1,19 +1,21 @@ #ifndef ARBUTILS_EXCEPTION_HPP #define ARBUTILS_EXCEPTION_HPP -#if !WINDOWS -#define BACKWARD_HAS_BFD 1 -#endif #include #include #include #include +#if !WINDOWS +#define BACKWARD_HAS_BFD 1 #include "../extern/backward.hpp" +#endif namespace ArbUt { class Exception : std::exception { std::string _msg; +#if !WINDOWS backward::StackTrace _stack; +#endif public: explicit Exception(std::string msg) : _msg(std::move(msg)) { _stack.load_here(9); } @@ -21,6 +23,7 @@ namespace ArbUt { [[nodiscard]] const char* what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW override { return _msg.c_str(); } [[nodiscard]] std::string GetStacktrace(size_t depth = 6, bool include_addr = true) const { +#if !WINDOWS backward::TraceResolver tr; tr.load_stacktrace(_stack); std::stringstream ss; @@ -54,6 +57,9 @@ namespace ArbUt { } } return ss.str(); +#else + return "Stack trace not available on Windows."; +#endif } }; }