C++ exception handling is the most important improvement of C++. Unfortunately it is also the most underused feature. Somehow some people seem to have an aversion against it.
C++ Exception handling enables the abortion of the construction of an object. This in turn allows the usage of constructors for the allocation of fallible objects, like e.g. filedescriptors.
C++ exception handling also allows one to write code, which relies on the fact that all preceding code executed successfully without the need to check for success. This is mostly used for creating complex classes consisting of multiple member and/or base classes. When using C++ exception handling to report errors one can be certain, that during the execution of some constructor that prior member or base class objects were created successfully.
The
curious thing is that most software engineers and managers don't care. Most
software engineers even don't know about the effect it could have on their
software. Some other software engineers consider it as too difficult to manage
-- similar to Multi-Threading (I don't consider Multi-Threading as too
difficult to manage!).
|