--  Exception_Information gives the name and the message; Reraise_Occurrence of a handler's
--  own occurrence propagates it, message and all, as `raise;` does.
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;

procedure Main is
   Failure : exception;
   Plain : exception;

   procedure Inner (With_Message : Boolean)
     with Global => (In_Out => Ada.Text_IO.File_System),
          Exceptional_Cases => (Failure => With_Message, Plain => not With_Message)
   is
   begin
      if With_Message then
         raise Failure with "disk full";
      else
         raise Plain;
      end if;
   exception
      when X : Failure | Plain =>
         Put_Line ("inner: " & Exception_Information (X));
         Reraise_Occurrence (X);
   end Inner;
begin
   for M in Boolean loop
      begin
         Inner (M);
      exception
         when Y : Failure | Plain =>
            Put_Line ("outer: " & Exception_Name (Y) & " [" & Exception_Message (Y) & "]");
      end;
   end loop;
end Main;
