KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I searched the Internet and found a lot of articles about this topic. However, I found there is no complete checklist to verify our code's quality of exception-safety. So, I want to collect valuable best practices for C++ exception handling from you. I first list some practices of my own: Catch all exceptions if any in destructors: struct A { ~A() { try { // Here may throw exceptions } catch (std::runtime_error& e) {} catch (...) { logging("..."); } } }; Add function name, source file name and line numer in exception information. __func__ , __FILE__ and __LINE__ are good friends. Never use exception specifications. The reason is given in the book "C++ Coding Standards". What are yours?
Tags (comma-separated)
Save Edits
Cancel