From 58970bf1eaf5d065b2db0ebe248bc96c51a5b4ca Mon Sep 17 00:00:00 2001 From: gabi Date: Mon, 1 Dec 2014 22:25:31 +0200 Subject: [PATCH] Rethrow cppformat exceptions as spdlog_ex with description of the bad format string --- include/spdlog/details/logger_impl.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index d11c8164..830136aa 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -71,7 +71,17 @@ inline spdlog::details::line_logger spdlog::logger::log(level::level_enum lvl, c bool msg_enabled = should_log(lvl); details::line_logger l(this, lvl, msg_enabled); if (msg_enabled) - l.write(fmt, args...); + { + try + { + l.write(fmt, args...); + } + catch(const fmt::FormatError& e) + { + throw spdlog_ex(fmt::format("formatting error while processing format string '{}': {}", fmt, e.what())); + } + + } return l; }