From 65506136e2916e7956368234b97e1ff66b73f056 Mon Sep 17 00:00:00 2001 From: gabime Date: Wed, 13 Jun 2018 19:10:22 +0300 Subject: [PATCH] solve issue #724 --- include/spdlog/common.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 225d2952..d6138fc5 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -148,28 +148,26 @@ namespace os { std::string errno_str(int err_num); } } // namespace details -class spdlog_ex : public std::exception +class spdlog_ex : public std::runtime_error { public: - explicit spdlog_ex(std::string msg) - : _msg(std::move(msg)) + spdlog_ex(const std::string &msg): runtime_error(msg) { + fmt::format_to(buf_, "{}", msg); } - spdlog_ex(const std::string &msg, int last_errno) + spdlog_ex(const std::string &msg, int last_errno): runtime_error(msg) { - fmt::memory_buffer buf; - fmt::format_system_error(buf, last_errno, msg); - _msg = fmt::to_string(buf); + fmt::format_system_error(buf_, last_errno, msg); } const char *what() const SPDLOG_NOEXCEPT override { - return _msg.c_str(); + return fmt::to_string(buf_).c_str(); } - + private: - std::string _msg; + fmt::memory_buffer buf_; }; //