The Ada Program: fragment1.adb

  1 --: an Ada block declaring, raising, and handling exceptions
  2 
  3 Block_X: declare
  4 
  5    E: exception;
  6 
  7    procedure P (N: Integer) is
  8       F: exception;
  9    begin
 10       Put_Line ("Call P");
 11       if N=2 then raise E end if;
 12       if N=3 then raise F end if;
 13    exception
 14       when E => Put_Line ("E1");
 15    end P;
 16 
 17 begin
 18 
 19     P(1);  P(2);  P(3);  P(4);
 20 
 21 exception
 22 
 23     when E => Put_line ("E2");
 24 
 25 end Block_X;