From fd170b0fe13369f7152c8018cbf7df60500dfe53 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 24 Nov 2017 20:58:43 +0200 Subject: [PATCH] catch(...) exceptions, report it, and rethrow --- include/spdlog/details/async_log_helper.h | 8 +++++++- include/spdlog/details/async_logger_impl.h | 8 +++++++- include/spdlog/details/logger_impl.h | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index c7c5f860..7fb4922c 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -279,7 +279,13 @@ inline void spdlog::details::async_log_helper::worker_loop() catch (const std::exception &ex) { _err_handler(ex.what()); - } + } + catch(...) + { + _err_handler("Unknown exeption in worker loop. Terminating worker loop"); + active = false; + + } } if (_worker_teardown_cb) _worker_teardown_cb(); diff --git a/include/spdlog/details/async_logger_impl.h b/include/spdlog/details/async_logger_impl.h index 3964c5ab..1b8bd1ca 100644 --- a/include/spdlog/details/async_logger_impl.h +++ b/include/spdlog/details/async_logger_impl.h @@ -97,5 +97,11 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg) catch (const std::exception &ex) { _err_handler(ex.what()); - } + } + catch(...) + { + _err_handler("Unknown exception in logger " + _name); + throw; + } + } diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index bd7ead80..492a9461 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -76,6 +76,10 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Ar catch (const std::exception &ex) { _err_handler(ex.what()); + } + catch(...) { + _err_handler("Unknown exception in logger " + _name); + throw; } }