comp.lang.ada
 help / color / mirror / Atom feed
* Exception'IMAGE in Ada9X?
@ 1992-12-02  3:42 Kenneth Anderson
  0 siblings, 0 replies; 4+ messages in thread
From: Kenneth Anderson @ 1992-12-02  3:42 UTC (permalink / raw)


Hi,

Does anyone know if they plan to have a feature in Ada9X that would get
rid of code that looks like this...

procedure Buggy is
begin
 ...
exception
  when CONSTRAINT_ERROR => Text_IO.PUT_LINE("CONSTRAINT_ERROR in Buggy");
  when NUMERIC_ERROR    => Text_IO.PUT_LINE("NUMERIC_ERROR in Buggy");
  when STORAGE_ERROR    => Text_IO.PUT_LINE("STORAGE_ERROR in Buggy");
  when others           => Text_IO.PUT_LINE("Fatal Error in Buggy");
end Buggy;

and replace it with something like

procedure Buggy is
begin
 ...
exception
   when others => Text_IO.PUT_LINE(exception'IMAGE);
end Buggy;


Notes:  The above code does not imply that only buggy code should have
        exception handlers.

        I realize that I used 'IMAGE in the wrong fashion. I.E. Normally
        you would see something like T'IMAGE(Var_of_type_T). I just
        wanted to convey the notion of being able to print out what
        the exception is without coding a seperate when statement
        for all possible exceptions (including user defined exceptions).

Thanks in advance,

Ken Anderson

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Exception'IMAGE in Ada9X?
@ 1992-12-02  4:08 dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!darwin.sura.net!zaphod
  0 siblings, 0 replies; 4+ messages in thread
From: dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!darwin.sura.net!zaphod @ 1992-12-02  4:08 UTC (permalink / raw)


In article <9212011938.aa08479@Paris.ics.uci.edu> kanderso@liege.ICS.UCI.EDU (K
enneth Anderson) writes:
>Hi,
>
>Does anyone know if they plan to have a feature in Ada9X that would get
>rid of code that looks like this...
>
>procedure Buggy is
>begin
> ...
>exception
>  when CONSTRAINT_ERROR => Text_IO.PUT_LINE("CONSTRAINT_ERROR in Buggy");
>  when NUMERIC_ERROR    => Text_IO.PUT_LINE("NUMERIC_ERROR in Buggy");
>  when STORAGE_ERROR    => Text_IO.PUT_LINE("STORAGE_ERROR in Buggy");
>  when others           => Text_IO.PUT_LINE("Fatal Error in Buggy");
>end Buggy;
>
>and replace it with something like
>
>procedure Buggy is
>begin
> ...
>exception
>   when others => Text_IO.PUT_LINE(exception'IMAGE);
>end Buggy;
>

Ask, and ye shall receive...
Turning to my trusty 9X Mapping Rationale (4.1 for you other
reviewers out there -- if my info is dated, please shout):
the example actually goes like this:
...
begin
...
exception
   when E : others =>
      -- Unhandled exception; log it
      Put(Log_File,
          "Unknown error in task Some_Task: "
          & System.Exception_Name(E)
          & System.Exception_Information(E));
      ...  -- Reset data structures as necesary.
end;
...

There's also talk of a third goodie, a type called Exception_Occurrence.
This type can provide other useful tidbits like stack-traces.

Pay careful attention to the different syntax in the "when" clause,
cuz it ain't no typo!  This gives us a variable name for our exception,
which is used when we call Exception_Name.

Hope this helped.

dgw

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Exception'IMAGE in Ada9X?
@ 1992-12-02  5:57 Kenneth Anderson
  0 siblings, 0 replies; 4+ messages in thread
From: Kenneth Anderson @ 1992-12-02  5:57 UTC (permalink / raw)


In comp.lang.ada you write:

>In an article kanderso@liege.ICS.UCI.EDU (Kenneth Anderson) writes:

>> <question about Ada9X feature deleted>

>Ask, and ye shall receive...
>Turning to my trusty 9X Mapping Rationale (4.1 for you other
>reviewers out there -- if my info is dated, please shout):
>the example actually goes like this:
>...
>begin
>...
>exception
>   when E : others =>
>      -- Unhandled exception; log it
>      Put(Log_File,
>          "Unknown error in task Some_Task: "
>          & System.Exception_Name(E)
>          & System.Exception_Information(E));
>      ...  -- Reset data structures as necesary.
>end;
>...

>There's also talk of a third goodie, a type called Exception_Occurrence.
>This type can provide other useful tidbits like stack-traces.

>Pay careful attention to the different syntax in the "when" clause,
>cuz it ain't no typo!  This gives us a variable name for our exception,
>which is used when we call Exception_Name.

>Hope this helped.

Thanks.  If only we had this feature now!  Well, this gives me yet another
reason to look forward to Ada9X!!

Thanks for the quick response,

>dgw

Ken

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Exception'IMAGE in Ada9X?
@ 1992-12-02 14:31 enterpoop.mit.edu!linus!linus.mitre.org!news!emery
  0 siblings, 0 replies; 4+ messages in thread
From: enterpoop.mit.edu!linus!linus.mitre.org!news!emery @ 1992-12-02 14:31 UTC (permalink / raw)


There is an old ALIWG recommendation on this topic, which is currently
supported by many compilers: As I recall, it is something like:

	package CURRENT_EXCEPTION is
	  function EXCEPTION_NAME
	      return STRING;
	end CURRENT_EXCEPTION;

This was the basis for the 9X feature.

				dave

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1992-12-02 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-12-02  5:57 Exception'IMAGE in Ada9X? Kenneth Anderson
  -- strict thread matches above, loose matches on Subject: below --
1992-12-02 14:31 enterpoop.mit.edu!linus!linus.mitre.org!news!emery
1992-12-02  4:08 dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!darwin.sura.net!zaphod
1992-12-02  3:42 Kenneth Anderson

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