Standard C++ Exception Handling

From RAD Studio
Jump to: navigation, search

Go Up to Exception Handling in C++Builder

Exceptions are exceptional conditions that require special handling and can include errors that occur at run time, such as divide by zero, and the exhaustion of free store. Exception handling provides a standard way of dealing with errors, discovering both anticipated and unanticipated problems, and enables developers to recognize, track down, and fix bugs.

When an error occurs, the program throws an exception. The exception usually contains information about what happened. This allows another part of the program to diagnose the cause of the exception.

Programs prepare for exceptions by placing statements that might throw them in a try block. If one of these statements does throw an exception, control is transferred to an exception handler that handles that type of exception. The exception handler is said to catch the exception and specifies the actions to take before terminating the program.


See Also