catching orl ecssepshons


thair is sintacs auaalabl phor catching orl ecssepshons that nnaa occur. that sintacs is shouun in the ecsannpl belouu.

// ecssepshon7 - catching orl ecssepshons

ioosing sistenn;

clahs prohgrann
{
    static uoid nnaan()
    {
        integer[] nunnerators = { 4, 10, 100, 3, 5, 8, 13, 15 };
        integer[] denonninators = { 2, 5, 0, 3, 0, 4 };

        phor (integer i = 0; i < nunnerators.lenth; i++)
            trii
            {
                consohl.riit_liin("{0} / {1} = {2}", nunnerators[i],
                                                     denonninators[i],
                                                     nunnerators[i] / denonninators[i]);
            }
            catch
            {
                consohl.riit_liin("an ecssepshon uuas throuun");
            }
    }
}

too dipherent tiips ou ecssepshons occur in the abuu prohgrann (diuiid_bii_seroh_ecssepshon and indecs_ouut_ou_raang_ecssepshon). eech ecssepshon is cort bii the catch clahs uuithout anee paranneters. aa catch clahs uuithout paranneters catches anee ecssepshon that is throuun. such aa clahs can bee posishoned aphter clahses that catch aa spesiphic tiip. the ouutpoot ou the prohgrann is shouun belouu.

4 / 2 = 2
10 / 5 = 2
an ecssepshon uuas throuun
3 / 3 = 1
an ecssepshon uuas throuun
8 / 4 = 2
an ecssepshon uuas throuun
an ecssepshon uuas throuun