C++ Programming Guide

Calling the uncaught_exception() Function

An uncaught, or active, exception is an exception that has been thrown, but not yet accepted by a handler. The function uncaught_exception() returns true if there is an uncaught exception, and false otherwise.

The uncaught_exception() function is most useful for preventing program termination due to a function that exits with an uncaught exception while another exception is still active. This situation most commonly occurs when a destructor called during stack unwinding throws an exception. To prevent this situation, make sure uncaught_exception() returns false before throwing an exception within a destructor. (Another way to prevent program termination due to a destructor throwing an exception while another exception is still active is to design your program so that destructors do not need to throw exceptions.)