Exceptions in C++

The notion of exception is provided to help get information from the point where an error is detected to a point where this error could be handled.

A called function cannot just return with an indication that an error happened. If the program is to continue working, the returning function must leave the program in a good state and not leak any resources.

An exception is an object thrown to represent the occurrence of an error.

An exception is caught by code that has expressed interest in handling this particular type of exception.

Exceptions make the complexity of error handling visible. However, exceptions are not the cause of that complexity. Be careful not to blame the messenger for bad news.