Generate Stacktrace fixed
This commit is contained in:
parent
7197433905
commit
a621370270
@ -10,9 +10,13 @@ class BasicException : public std::exception {
|
|||||||
public:
|
public:
|
||||||
BasicException(const std::string &message, uint64_t stacktrace_size) noexcept
|
BasicException(const std::string &message, uint64_t stacktrace_size) noexcept
|
||||||
: message_(message),
|
: message_(message),
|
||||||
stacktrace_size_(stacktrace_size) {}
|
stacktrace_size_(stacktrace_size) {
|
||||||
|
generate_stacktrace();
|
||||||
|
}
|
||||||
BasicException(const std::string &message) noexcept : message_(message),
|
BasicException(const std::string &message) noexcept : message_(message),
|
||||||
stacktrace_size_(10) {}
|
stacktrace_size_(10) {
|
||||||
|
generate_stacktrace();
|
||||||
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
BasicException(const std::string &format, Args &&... args) noexcept
|
BasicException(const std::string &format, Args &&... args) noexcept
|
||||||
@ -24,8 +28,8 @@ class BasicException : public std::exception {
|
|||||||
std::string message_;
|
std::string message_;
|
||||||
uint64_t stacktrace_size_;
|
uint64_t stacktrace_size_;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
void generate_stacktrace() {
|
void generate_stacktrace() {
|
||||||
|
#ifndef NDEBUG
|
||||||
Stacktrace stacktrace;
|
Stacktrace stacktrace;
|
||||||
|
|
||||||
int size = std::min(stacktrace_size_, stacktrace.size());
|
int size = std::min(stacktrace_size_, stacktrace.size());
|
||||||
@ -33,6 +37,6 @@ class BasicException : public std::exception {
|
|||||||
message_.append(fmt::format("\n at {} ({})", stacktrace[i].function,
|
message_.append(fmt::format("\n at {} ({})", stacktrace[i].function,
|
||||||
stacktrace[i].location));
|
stacktrace[i].location));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user