Uncaught Exceptions Catch All Handlers And Exception Specifiers

Uncaught Exceptions

When an exception is not caught, the operating system will decide how to handle it. In general, all exceptions should be caught.

Catch-all handlers

Use of the ellipses operator (…) as the type to catch. The catch-all handler should be placed last in the catch block chain.

Example

try
{
    throw 5; // throw an int exception
}
catch (double dX)
{
    cout << "We caught an exception of type double: " << dX << endl;
}
catch (...) // catch-all handler
{
    cout << "We caught an exception of an undetermined type" << endl;
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.