Completely not include the stacktrace on Windows.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
e778b61839
commit
c7d18db8b7
|
@ -1,19 +1,21 @@
|
||||||
#ifndef ARBUTILS_EXCEPTION_HPP
|
#ifndef ARBUTILS_EXCEPTION_HPP
|
||||||
#define ARBUTILS_EXCEPTION_HPP
|
#define ARBUTILS_EXCEPTION_HPP
|
||||||
#if !WINDOWS
|
|
||||||
#define BACKWARD_HAS_BFD 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#if !WINDOWS
|
||||||
|
#define BACKWARD_HAS_BFD 1
|
||||||
#include "../extern/backward.hpp"
|
#include "../extern/backward.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ArbUt {
|
namespace ArbUt {
|
||||||
class Exception : std::exception {
|
class Exception : std::exception {
|
||||||
std::string _msg;
|
std::string _msg;
|
||||||
|
#if !WINDOWS
|
||||||
backward::StackTrace _stack;
|
backward::StackTrace _stack;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Exception(std::string msg) : _msg(std::move(msg)) { _stack.load_here(9); }
|
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]] 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 {
|
[[nodiscard]] std::string GetStacktrace(size_t depth = 6, bool include_addr = true) const {
|
||||||
|
#if !WINDOWS
|
||||||
backward::TraceResolver tr;
|
backward::TraceResolver tr;
|
||||||
tr.load_stacktrace(_stack);
|
tr.load_stacktrace(_stack);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -54,6 +57,9 @@ namespace ArbUt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
#else
|
||||||
|
return "Stack trace not available on Windows.";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue