comp.lang.ada
 help / color / mirror / Atom feed
From: wdl39!mab@ford-wdl1.arpa  (Mark A Biggar)
Subject: Re: simple exception-handler
Date: 8 Feb 93 22:40:16 GMT	[thread overview]
Message-ID: <1993Feb8.224016.23018@wdl.loral.com> (raw)

In article <otte.2.0@antpc.ant.uni-hannover.de> otte@antpc.ant.uni-hannover.de 
(Herr Otte) writes:
>While I am trying to test my packages and subprograms,
>I want to write an exception-handler, which only puts
>the name of the raised exception to the standard output.
>The first solution, that I found, was :
>with Text_IO ;
>procedure Error_IO_Test is
>...
>exception
>  when CONSTRAINT_ERROR => Text_IO.Put_Line ("CONSTRAINT_ERROR");
>  when NUMERIC_ERROR    => Text_IO.Put_Line ("NUMERIC_ERROR");
>  when PROGRAM_ERROR    => Text_IO.Put_Line ("PROGRAM_ERROR");
>  when STORAGE_ERROR    => Text_IO.Put_Line ("STORAGE_ERROR");
>  when TASKING_ERROR    => Text_IO.Put_Line ("TASKING_ERROR");
>end Error_IO_Test;
>The number of lines in the exception-handler will increase,
>if I take care not only for the standard exceptions, but for
>the Text_IO exceptions and my own user-defined exceptions.
>For this reason, I prefer a solution like this :
>with Text_IO ;
>procedure Error_IO_Test is
>...
>exception
>  when others => Text_IO.Put_Line ( <Name_of_the_Error> );
>end Error_IO_Test;
>Of course, the above solution with Text_IO doesn't work.
>Do there really exist a solution, that is easier than
>writing all the names of all known exceptions ?

No help in Ada83 but in Ada9x you will be able to say:

with Text_IO;
procedure Error_IO_Test is
...
exception
    when E: others => Text_IO.Put_Line(Exception_Name(E));
end Error_IO_Test;

There will also be a function Exception_Occurence that will return
an implementation defined value describing the context of the actual
exception.

--
Mark Biggar
mab@wdl1.wdl.loral.com

             reply	other threads:[~1993-02-08 22:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-02-08 22:40 Mark A Biggar [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-02-09 10:41 simple exception-handler Alain Marpinard
1993-02-09  1:59 David Emery
1993-02-08 19:36 cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!h
1993-02-08 18:27 Kenneth Anderson
1993-02-08 10:21 enterpoop.mit.edu!ira.uka.de!Germany.EU.net!urmel.informatik.rwth-aachen.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox