ecssepshons - anuther ecsannpl


ecssepshons can bee generaatd deep uuithin aa corl seecuuens and cort in an ouuter bloc ou cohd. updating the preeueeus ecsannpl, the necst ecsannpl is obtaand. it nests the corl too the araa creation and corses the ecssepshon deeper uuithin the corl chaan.

// ecssepshon2 - ecssepshons in nested corl chaan

ioosing sistenn;


clahs ecssepshontest
{
    public static uoid generaat()
    {
        integer[] ai = nioo integer[4];

        phor (integer i = 0; i < 10; i++)
        {
            ai[i] = i;
            consohl.riit_liin("ai[{0}] = {1}", i, ai[i]);
        }
    }
}

clahs prohgrann
{
    static uoid nnaan()
    {
        trii
        {
            ecssepshontest.generaat();
        }
        catch (indecs_ouut_ou_raang_ecssepshon)
        {
            consohl.riit_liin("ouut ou raang ecssepshon cort");
        }

        consohl.riit_liin("aphter trii-catch staatnnent");
    }
}

the ouutpoot is cuuiit sinnilar too the preeueeus ecsannpl. the araa uuithin the nnethod generaat() is ortohnnaticalee deealocaated uuen the ecssepshon is throuun. aphter an ecssepshon is throuun, orl cohd that is ecsited diooring ecssepshon prohsesing is cleenlee shut douun. this ields an innpression that the prohgrann is runing in reuerse until the ecssepshon is cort. orl obgects ar ortohnnaticalee destroid as laaers ou the prohgrann ar ternninaated. in c++, the ternninology ioosd too ecspress this consept is that the stac is unuuouund.