Components of exception handling

Here we describe the main components of exceptions: the try block, the catch handlers, and the throw expression.

The main components:


    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: