From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5bb6410b5c961c45 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: New tools and old exceptions Date: 1997/05/21 Message-ID: <01bc6631$a8d47da0$8e8871a5@craig-s-pc>#1/1 X-Deja-AN: 243561197 Distribution: world References: <3.0.32.19970519223408.0070cc14@mail.4dcomm.com> Organization: interQuest Online Services -- Huntsville, AL Newsgroups: comp.lang.ada Date: 1997-05-21T00:00:00+00:00 List-Id: Here's an excerpt from an internal e-mail to one of my colleagues just last week which, I believe, gives the information pertinent to your query. ---- begin excerpt ----- In general however, you can make such exception messages more informative in Ada95 by doing the following: 1. with Ada.Exceptions; 2. Make your exception handlers look something like the following: exception when E: others=> Ada.Text_IO.Put_Line ("Exception caught in main procedure"); Ada.Text_IO.Put_Line ("Exception information:") Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); end; The "E" in this case (any identifier will do) identifies the exception occurrence, and is declared "on the fly" by placing it immediately following the "when" in an exception handler, followed by the colon. Then this identifier can be passed to any of the subprograms declared in Ada.Exceptions with parameters of type Exception_ID. The exception information can include a message provided at the point the exception was raised. The way this is done is -- instead of a statement like "raise My_Exception;" you would say Ada.Exceptions.Raise_Exception (E => My_Exception'Identity, Message "raised in My_Package.My_Subprogram because ......"); This enhanced exception capability in Ada95 makes it possible to place all of the relevant information about an exception in the message (including relevant data values, etc.) at the point it is raised. Then if it's an exception which should never occur, the exception never need be handled explicitly, but it can be implicitly handled in a "when others" handler in the main program, and still have all of the relevant information about where and why it was raised. ------ end excerpt ------ I hope this helps. David C. Hoos, Sr. http://www.ada95.com http://www.dbhwww.com Robert C. Leif, Ph.D. wrote in article <3.0.32.19970519223408.0070cc14@mail.4dcomm.com>... > From: Bob Leif, Ph.D. > To: Comp.Lang.Ada > > Many of us need all of the help that we can get. Ada.Exceptions has a > function Exception_Information(X: Exception_Occurrence) return string; > Exception_Occurrence is limited private and no simple information is given > on how to call Exception_Occurrence as an argument based on a name such as > Constraint_Error. > From the error messages that I have been generating, Constraint_Error is an > exception not an Occurrence. > Therefore how does one > Exception > When Constraint_Error => > obtain the Exception_Information on the Constraint_Error? > I am posting this to Comp.Lang.Ada; since, I do not believe that this is a > GNAT problem. > > I would also like to note for the text book authors, that describing in > detail how to maximize the information available in the Ada exception > handler would be appreciated by the students and other readers. > > Thank you. > Bob Leif >