--  a handler that names its occurrence: the exception's name and message
with Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;

procedure Main is
   Bad_Input : exception;

   procedure Check (N : Integer)
     with Exceptional_Cases => (Bad_Input => N < 0)
   is
   begin
      if N < 0 then
         raise Bad_Input with "negative:" & Integer'Image (N);
      end if;
   end Check;
begin
   Check (3);
   begin
      Check (-4);
   exception
      when E : Bad_Input =>
         Put_Line ("handled " & Ada.Exceptions.Exception_Name (E));
         Put_Line ("message """ & Ada.Exceptions.Exception_Message (E) & """");
   end;
end Main;
