comp.lang.ada
 help / color / mirror / Atom feed
From: "Samuel A. Mize" <smize@magellan.bgm.link.com>
Subject: Re: New tools and old exceptions
Date: 1997/05/20
Date: 1997-05-20T00:00:00+00:00	[thread overview]
Message-ID: <3381B9FA.41C6@magellan.bgm.link.com> (raw)
In-Reply-To: 3.0.32.19970519223408.0070cc14@mail.4dcomm.com


Robert C. Leif, Ph.D. wrote:
> 
> From: Bob Leif, Ph.D.
> To: Comp.Lang.Ada
> 
> ... 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?

Check the example in RM 11.4.2.

Quick info:

- To get ahold of the current Exception_Occurrence in a handler, put a
  parameter in the "when" clause:

    begin
      null;
    when E: others =>
      -- E is implicitly of type Exception_Occurrence
      Text_Io.Put_Line
        ("DIE DIE DIE " & Ada.Exceptions.Exception_Information (E);
    end;

- To just raise a given exception, use a "raise" statement:

    raise Constraint_Error;

- But to raise it and attach your own text (which can then be retrieved
  by Exception_Information) use Exceptions.Raise_Exception, using the
  'Identity attribute to get the exception's ID:

    Ada.Exceptions.Raise_Exception
      (Constraint_Error'Identity,
       "Failed in region 7 due to stupid user error");

Samuel Mize

> 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

-- Samuel Mize           (817) 619-8622               "Team Ada"
-- Hughes Training Inc.  PO Box 6171 m/s 400, Arlington TX 76005




  parent reply	other threads:[~1997-05-20  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-19  0:00 New tools and old exceptions Robert C. Leif, Ph.D.
1997-05-20  0:00 ` Stephen Leake
1997-05-20  0:00 ` Jeff Carter
1997-05-20  0:00 ` Samuel A. Mize [this message]
1997-05-21  0:00 ` David C. Hoos, Sr.
replies disabled

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