From c204e8dc7e0d4f1317747d5f7f2e17aab449de1a Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 11 Jan 2015 00:56:25 +0100 Subject: Added ExceptionLogger class which directly throws any reported error. --- src/core/common/Logger.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/core/common/Logger.hpp b/src/core/common/Logger.hpp index d3a5892..b365a39 100644 --- a/src/core/common/Logger.hpp +++ b/src/core/common/Logger.hpp @@ -657,6 +657,25 @@ public: } }; +/** + * Logger instance which throws each encountered error as LoggableException. + */ +class ExceptionLogger : public Logger { +protected: + /** + * Throws errors and fatal errors as exception. + * + * @param msg is the message that should be thrown as exception. + */ + void processMessage(const Message &msg) override + { + if (msg.severity == Severity::ERROR || + msg.severity == Severity::FATAL_ERROR) { + throw LoggableException(msg.msg); + } + } +}; + #ifdef NDEBUG constexpr Severity DEFAULT_MIN_SEVERITY = Severity::NOTE; #else -- cgit v1.2.3