Completely not include the stacktrace on Windows.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-08-15 14:22:32 +02:00
parent e778b61839
commit c7d18db8b7
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 9 additions and 3 deletions

View File

@ -1,19 +1,21 @@
#ifndef ARBUTILS_EXCEPTION_HPP
#define ARBUTILS_EXCEPTION_HPP
#if !WINDOWS
#define BACKWARD_HAS_BFD 1
#endif
#include <exception>
#include <sstream>
#include <string>
#include <utility>
#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
}
};
}