From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,MSGID_SHORT autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 9 Feb 93 10:41:15 GMT From: enterpoop.mit.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU. net!mcsun!julienas!cix!insage!marpinar@ucbvax.Berkeley.EDU (Alain Marpinard) Subject: Re: simple exception-handler Message-ID: <2838@cix.cict.fr> List-Id: In article 0@antpc.ant.uni-hannover.de, otte@antpc.ant.uni-hannover.de (Herr Ot te) 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 ( ); >end Error_IO_Test; In Ada 9X Mapping (Version 4.0, Intermetrics, December 91), you find this definition of exception handlers : exception_handler_part ::= exception exception_handler {exception_handler} exception_handler ::= when [choice_parameter:] exception_choice {| exception_choice} => sequence_of_statements choice_parameter ::= identifier and two supplementary functions are provided in SYSTEM: function EXCEPTION_NAME (X: EXCEPTION_OCCURRENCE) return STRING; function EXCEPTION_INFORMATION(X: EXCEPTION_OCCURRENCE) return STRING; So you will be able to write something like this: exception when ANY_EXCEPTION : others => Text_IO.Put_Line( EXCEPTION_NAME(ANY_EXCEPTION)); end Error_IO_Test; -- or something like this : -- Text_IO.Put_Line(OUTPUT_FILE, EXCEPTION_NAME(ANY_EXCEPTION) -- & " " & EXCEPTION_INFORMATION(ANY_EXCEPTION)); -- raise; >Dirk Otte >Institut fuer Allgemeine Nachrichtentechnik >Technische Universitaet Hannover >3000 Hannover 1 >Deutschland --------------------------------------------------------------------------- Alain MARPINARD marpinar@insage.insa-tlse.fr Fax : (33) 61 55 98 08 G.E.R.I.I. (Groupe d'Etude et de Recherche en Informatique Industrielle) D.G.E. (Departement Genie Electrique) I.N.S.A. (Institut National des Sciences Appliquees) ---------------------------------------------------------------------------