From b51264cc211bb6e6d1598fd0a2344a56bd3df11f Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 22 Mar 2025 10:08:54 +0000 Subject: Handle errors from {fmt} in Log::Manager::Write. --- include/logging.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/logging.h') diff --git a/include/logging.h b/include/logging.h index 01f9104bd..786ba19fe 100644 --- a/include/logging.h +++ b/include/logging.h @@ -261,7 +261,15 @@ private: if (maxlevel < level && !caching) return; // No loggers care about this message. - Write(level, type, fmt::vformat(format, fmt::make_format_args(args...))); + try + { + Write(level, type, fmt::vformat(format, fmt::make_format_args(args...))); + } + catch (const fmt::format_error& err) + { + // This should only ever happen when we encounter a bug. + Write(Log::Level::CRITICAL, "LOG", "BUG: failed to format a log message: {} -- {}", format, err.what()); + } } public: -- cgit v1.3.1-10-gc9f91