summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/common/Logger.hpp19
1 files changed, 19 insertions, 0 deletions
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