Add option to get depth of stack trace.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
f29e111b78
commit
5ac7654be1
|
@ -18,11 +18,11 @@ 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() const {
|
[[nodiscard]] std::string GetStacktrace(size_t depth = 6) const {
|
||||||
backward::TraceResolver tr;
|
backward::TraceResolver tr;
|
||||||
tr.load_stacktrace(_stack);
|
tr.load_stacktrace(_stack);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
for (size_t i = 3; i < _stack.size(); ++i) {
|
for (size_t i = 3; i < _stack.size() && i < depth + 3; ++i) {
|
||||||
backward::ResolvedTrace trace = tr.resolve(_stack[i]);
|
backward::ResolvedTrace trace = tr.resolve(_stack[i]);
|
||||||
if (trace.source.filename.empty()){
|
if (trace.source.filename.empty()){
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,8 @@ TEST_CASE("Throw exception, get stack trace") {
|
||||||
throw ArbUt::Exception("foobar");
|
throw ArbUt::Exception("foobar");
|
||||||
}
|
}
|
||||||
catch (const ArbUt::Exception& e) {
|
catch (const ArbUt::Exception& e) {
|
||||||
REQUIRE(e.GetStacktrace() ==
|
REQUIRE(e.GetStacktrace(1) ==
|
||||||
"ExceptionTests.cpp[8] ____C_A_T_C_H____T_E_S_T____0()\n"
|
"ExceptionTests.cpp[8] ____C_A_T_C_H____T_E_S_T____0()\n");
|
||||||
"catch.hpp[14036] Catch::TestInvokerAsFunction::invoke() const\n"
|
|
||||||
"catch.hpp[13929] Catch::TestCase::invoke() const\n"
|
|
||||||
"catch.hpp[12791] Catch::RunContext::invokeActiveTestCase()\n"
|
|
||||||
"catch.hpp[12756] Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, ...\n"
|
|
||||||
"catch.hpp[12525] Catch::RunContext::runTest(Catch::TestCase const&)\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue