diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-03-09 23:50:43 -0600 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-03-15 21:11:40 +0000 |
commit | 153311005f6c4f0de710adebaf93a98cc2ca8ebc (patch) | |
tree | 2032a8d03490b8a7c4dd56691188385d5fcf5676 /logging_test.cpp | |
parent | 682326a19c45b68299cb295b69754a9eb3154f48 (diff) | |
download | phosphor-logging-153311005f6c4f0de710adebaf93a98cc2ca8ebc.tar.gz phosphor-logging-153311005f6c4f0de710adebaf93a98cc2ca8ebc.zip |
Map sdbusplus exception to phosphor exception
Errors will be created by using the sdbusplus error types, which results
in an sdbusplus exception being thrown.
Error metadata can be verified at compile-time by checking the error
against phosphor-logging error types. This commit maps the sdbusplus
error type to the phosphor type, for this purpose, via template
specializations.
Change-Id: Iee37e2a3846cc3acf3a62270a520ff0c395fd36d
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'logging_test.cpp')
-rw-r--r-- | logging_test.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/logging_test.cpp b/logging_test.cpp index f9d9739..2325444 100644 --- a/logging_test.cpp +++ b/logging_test.cpp @@ -4,8 +4,10 @@ #include <iostream> #include <systemd/sd-journal.h> #include <sstream> +#include <sdbusplus/exception.hpp> #include <phosphor-logging/elog.hpp> #include <phosphor-logging/log.hpp> +#include <phosphor-logging/elog-errors.hpp> using namespace phosphor; using namespace logging; @@ -97,8 +99,7 @@ int elog_test() example::xyz::openbmc_project::Example::Elog:: TestErrorTwo::DEV_NAME("test case 3")); } - catch (elogException<example::xyz::openbmc_project::Example::Elog:: - TestErrorOne>& e) + catch (example::xyz::openbmc_project::Example::Elog::TestErrorOne& e) { std::cout << "elog exception caught: " << e.what() << std::endl; } @@ -150,7 +151,7 @@ int elog_test() TestErrorTwo::DEV_ID(100), TestErrorTwo::DEV_NAME("test case 4")); } - catch (elogExceptionBase& e) + catch (sdbusplus::exception_t& e) { std::cout << "elog exception caught: " << e.what() << std::endl; } @@ -214,8 +215,8 @@ void commitError(const char *text) example::xyz::openbmc_project::Example::Elog:: AutoTestSimple::STRING("FOO")); } - catch (elogException<example::xyz::openbmc_project::Example::Elog:: - AutoTestSimple>& e) + catch (example::xyz::openbmc_project::Example::Elog:: + AutoTestSimple& e) { std::cout << "elog exception caught: " << e.what() << std::endl; commit(e.name()); |