diff options
author | Andrew Geissler <andrewg@us.ibm.com> | 2016-10-16 20:49:14 -0500 |
---|---|---|
committer | Andrew Geissler <andrewg@us.ibm.com> | 2016-11-02 15:45:19 -0500 |
commit | 6d910ad9e2b3c83d7dccbcf25f9bdce9e4b13a58 (patch) | |
tree | fe624b401cc6e428d98f1c87113450703dc34dbf /logging_test.cpp | |
parent | 328889d5a6d0926f4876f3692713a759185812e1 (diff) | |
download | phosphor-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 'logging_test.cpp')
-rw-r--r-- | logging_test.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/logging_test.cpp b/logging_test.cpp index 5f153c1..9a638c3 100644 --- a/logging_test.cpp +++ b/logging_test.cpp @@ -70,9 +70,16 @@ int main() // TEST 3 - Create error log with 2 meta data fields (rvalue and lvalue) number = 0x1234; const char *test_string = "/tmp/test_string/"; - elog<file_not_found>(file_not_found::errnum(number), - file_not_found::file_path(test_string), - file_not_found::file_name("elog_test_3.txt")); + try + { + elog<file_not_found>(file_not_found::errnum(number), + file_not_found::file_path(test_string), + file_not_found::file_name("elog_test_3.txt")); + } + catch (elogException<file_not_found>& e) + { + std::cout << "elog exception caught: " << e.what() << std::endl; + } // Now read back and verify our data made it into the journal rc = validate_journal(file_not_found::errnum::str_short, @@ -92,10 +99,16 @@ int main() // TEST 4 - Create error log with previous entry use number = 0xFEDC; - elog<file_not_found>(file_not_found::errnum(number), - prev_entry<file_not_found::file_path>(), - file_not_found::file_name("elog_test_4.txt")); - + try + { + elog<file_not_found>(file_not_found::errnum(number), + prev_entry<file_not_found::file_path>(), + file_not_found::file_name("elog_test_4.txt")); + } + catch (elogExceptionBase& e) + { + std::cout << "elog exception caught: " << e.what() << std::endl; + } // Now read back and verify our data made it into the journal rc = validate_journal(file_not_found::errnum::str_short, std::to_string(number).c_str()); |