summaryrefslogtreecommitdiff
path: root/src/core/common/Logger.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-11 00:56:25 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-11 00:56:25 +0100
commitc204e8dc7e0d4f1317747d5f7f2e17aab449de1a (patch)
treea509c17d31714eacd6cbf5e317133dce1bace02a /src/core/common/Logger.hpp
parentb7d0f6517d19b6f8c544d6fa88a5f17b3c591a03 (diff)
Added ExceptionLogger class which directly throws any reported error.
Diffstat (limited to 'src/core/common/Logger.hpp')
-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