Here we describe the main components of exceptions: the try block, the catch handlers, and the throw expression.
The main components:
try block
catch handlers
throw expression
try
{
f();
// ...
}
catch (T1 e1) { /* handler for T1 */ }
catch (T2 e2) { /* handler for T2 */ }
catch (T3 e3) { /* handler for T3 */ }
void f()
{
//...
T e;
throw e; /* throws exception of type T */
// or:
throw T(); /* throws default value of T */
}
A hadler H triggers on exception E if:
H has same type as E
H is unambigous base type of E
H and E pointers or references and 1 or 2 holds