13.5. Uncaught Exceptions

When the exception mechanism searches catch handlers for a thrown exception, the signature of a catch handler must match the type of the exception. If a catch handler is not found as the stack unwinds, the exception is uncaught. By default, the exception mechanism calls terminate(), which stops your program. This section explores uncaught exceptions in more detail and shows you strategies for handling them in applications.

The terminate() Function

The exception mechanism calls terminate() with uncaught exceptions for any of the following reasons:

  • The exception mechanism cannot find a catch handler for a thrown exception in a program.

  • An exception object constructor throws an exception, either directly or indirectly, and ...

Get Navigating C++ and Object-Oriented Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.