summaryrefslogtreecommitdiffstats
path: root/elog.hpp
diff options
context:
space:
mode:
authorAndrew Geissler <andrewg@us.ibm.com>2016-10-16 20:49:14 -0500
committerAndrew Geissler <andrewg@us.ibm.com>2016-11-02 15:45:19 -0500
commit6d910ad9e2b3c83d7dccbcf25f9bdce9e4b13a58 (patch)
treefe624b401cc6e428d98f1c87113450703dc34dbf /elog.hpp
parent328889d5a6d0926f4876f3692713a759185812e1 (diff)
downloadphosphor-logging-6d910ad9e2b3c83d7dccbcf25f9bdce9e4b13a58.tar.gz
phosphor-logging-6d910ad9e2b3c83d7dccbcf25f9bdce9e4b13a58.zip
Add exception generation to error logging
This commit puts basic exception support into the elog class. All errors will generate an exception with this commit. This will most likely change over to using the dbus exception class as a base in the future but that change will be transperent to the users. Change-Id: Ibd02d4c204393a0cfb156805360161759cb6631e Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'elog.hpp')
-rw-r--r--elog.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/elog.hpp b/elog.hpp
index 090b5e9..b445a0e 100644
--- a/elog.hpp
+++ b/elog.hpp
@@ -66,6 +66,24 @@ template <typename T> using deduce_entry_type_t =
} // namespace details
+/**
+ * @brief Error log exception base class
+ *
+ * This allows people to capture all error log exceptions if desired
+ */
+class elogExceptionBase : public std::exception {};
+
+/**
+ * @brief Error log exception class
+ *
+ * This is for capturing specific error log exceptions
+ */
+template <typename T> class elogException : public elogExceptionBase
+{
+public:
+ const char* what() const noexcept override { return T::err_code; }
+};
+
/** @fn commit()
* @brief Create an error log entry based on journal
* entry with a specified MSG_ID
@@ -98,6 +116,9 @@ void elog(Args... i_args)
log<T::L>(T::err_msg,
details::deduce_entry_type<Args>{i_args}.get()...);
+
+ // Now throw an exception for this error
+ throw elogException<T>();
}
} // namespace logging
OpenPOWER on IntegriCloud