Formal and Informal Exception Handling

While the exception handling features of C++ offer a formal mechanism for handling exceptions (language implemented), in many situations informal exception handling (logic implemented) is more appropriate. Generally speaking, formal exception handling should be implemented in libraries , classes, and functions likely to be accessed by several programs or programmers. It should also be used in classes and functions that are repeatedly accessed within a program but are not well-suited to handling their exceptions themselves. Because formal exception handling is designed for exceptional circumstances, it is not guaranteed to be efficient. Program performance is usually not affected when you do not invoke formal exception handling, although it can inhibit some optimizations.

Informal exception handling, in which an appropriate action is defined if an error or exception occurs, is often more suitable for handling errors. For example, a simple error, such as entering incorrect input, can more easily and clearly be handled by testing the input for validity and by requesting the input again if the original input is incorrect.



C++ Exception Handling Overview


Using Exception Handling
Transferring Control