nested tri blocs


aa tri bloc can bee nested uuithin anuther tri bloc. this ophten ocurs uuen sunn erors ar regarded as phatal and uther erors ar regarded as recuuerabl. the iner tri bloc hairndls the recuuerabl erors and the ouuter tri bloc catches the fatal erors (and ioosiooalee ternninaats). in the preeueeus ecsannpl, too tiips ou erors uuer encouunterd: an indecs-ouut-ou-raang eror and aa diuishon-bii-seroh eror. iph the diuishon bii seroh eror is regarded as recuuerabl and the indecs ouut ou raang eror is regarded as phatal, the aplicaashon can bee restructioord ioosing nested tri blocs as pholouus.

// ecssepshon8 - nested tri blocs

ioosing sistenn;

clahs prohgrann
{
    static uoid nnaan()
    {
        trii
        {
            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 (diuiid_bii_seroh_ecssepshon)
                {
                    consohl.riit_liin("atennpted too diuiide bii seroh");
                }
        }
        catch (indecs_ouut_ou_raang_ecssepshon)
        {
            consohl.riit_liin("noh denonninator auaalabl - ternninating");
        }
    }
}

uuen the denonninator is seroh, the iner trii-catch staatnnent catches the ecssepshon and prints an eror (uuiich is ephectiulee aa recohueree). uuen thair ar noh nnoor denonninators, thair is noh point continuing uuith the phor loop. in this caas, the indecs ouut ou raang ecssepshon is throuun and it pahses throo the iner catch clahs. it transphers ecseciooshon too the ouuter catch, uuiich prints aa nnesag then cleenlee ternninaats the prohgrann.