Currently we throw only on unrecoverable failure resulting from an external source (like data for example) and have a single try catch around the entire execution.
When/Why/How should exceptions be used in modern C++?
Does C++11 change the answer to the above question?
Regarding the first part of the question (best-practices), standard reference is "Exception-Safety Issues and Techniques" part of "Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions" by Herb Sutter.
Addressing the C++11 part -- the following references might be helpful:
New exceptions-specific features have been added:
http://www2.research.att.com/~bs/C++0xFAQ.html#rethrow
http://www2.research.att.com/~bs/C++0xFAQ.html#noexcept
Even seemingly unrelated features are in fact very much related as far as their applications go: "The uses of unique_ptr include providing exception safety for dynamically allocated memory [...]" http://www2.research.att.com/~bs/C++0xFAQ.html#std-unique_ptr
Exception specifications have been deprecated: http://herbsutter.com/2010/03/13/trip-report-march-2010-iso-c-standards-meeting/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With