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 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 8 Feb 93 19:36:53 GMT From: cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!h owland.reston.ans.net!usc!news.cerf.net!shrike.irvine.com!adam@ucbvax.Berkeley. EDU (Adam Beneschan) Subject: Re: simple exception-handler Message-ID: List-Id: In article 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 ( ); > 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 ? There's no "Current Exception Name" function in Ada, but there's nothing barring Ada compiler vendors from including such a function in SYSTEM or in another vendor-supplied package. Our compiler does provide a function like that. You should check the Ada documentation that came with your compiler, or ask your vendor. Adam Beneschan Irvine Compiler Corporation