2016-05-10 05:30:13 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-06-15 06:06:21 +08:00
|
|
|
#include <fmt/format.h>
|
2016-09-05 17:02:48 +08:00
|
|
|
#include <stdexcept>
|
2016-05-10 05:30:13 +08:00
|
|
|
|
|
|
|
#include "utils/auto_scope.hpp"
|
2016-12-20 01:32:44 +08:00
|
|
|
#include "utils/stacktrace/stacktrace.hpp"
|
|
|
|
|
|
|
|
class BasicException : public std::exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BasicException(const std::string &message) noexcept : message_(message)
|
|
|
|
{
|
|
|
|
Stacktrace stacktrace;
|
|
|
|
message_.append(stacktrace.dump());
|
|
|
|
}
|
2016-08-31 03:52:46 +08:00
|
|
|
|
2016-12-20 01:32:44 +08:00
|
|
|
template <class... Args>
|
|
|
|
BasicException(const std::string &format, Args &&... args) noexcept
|
|
|
|
: BasicException(fmt::format(format, std::forward<Args>(args)...))
|
|
|
|
{
|
|
|
|
}
|
2016-08-31 03:52:46 +08:00
|
|
|
|
2016-12-20 01:32:44 +08:00
|
|
|
const char *what() const noexcept override { return message_.c_str(); }
|
2016-05-10 05:30:13 +08:00
|
|
|
|
2016-12-20 01:32:44 +08:00
|
|
|
private:
|
|
|
|
std::string message_;
|
2016-05-10 05:30:13 +08:00
|
|
|
};
|