comp.lang.ada
 help / color / mirror / Atom feed
From: gauthier@unilim.fr (Michel Gauthier)
Subject: Re: question on exceptions
Date: 1996/11/04
Date: 1996-11-04T00:00:00+00:00	[thread overview]
Message-ID: <gauthier-0411961631110001@164.81.60.62> (raw)
In-Reply-To: E090uD.Kx6@tip.nl


In article <E090uD.Kx6@tip.nl>, michiel.perdeck@cmg.nl wrote:

>>  [...]
>>  
>>  Questions:
>>      Unlike an exception in C++, an Ada exception cannot carry any
>>  extra information besides it's own name. [...]

Ada _can_ do this :
 - directly, in the case of String values,
 - indirectly, for every type with functions similar to
    the Image and Value attributes.

Attaching a String to a raise is a basic operation available
in the Ada.Exceptions predefined package.

For things other than String values, you can attach the Image
of what you want to attach. Inside the exception handler, you
can extract the message, and take its Value, which gets back
the initial value.

Caution : this works only if you can control that all raises are
correctly attached. Therefore, either you restrict such uses to
non-resusable parts, or you handle Constraint_Error possibly
caused by the back-parsing of the message.

----------          ----------          ----------          ---------- 
Michel Gauthier / Laboratoire d'informatique
123 avenue Albert Thomas / F-87060 Limoges
telephone + 33 () 05 55 45 73 35  [or ~ 72 32]
fax +33 () 05 55 45 73 15  [or ~72 01]  
    no initial zero from abroad ! ! !
----------          ----------          ----------          ----------
Si l'an 2000 est pour vous un mysticisme stupide, utilisez la base 9
If you feel year 2000 a stupid mystic craze, use numeration base 9
----------          ----------          ----------          ----------




      parent reply	other threads:[~1996-11-04  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-02  0:00 question on exceptions Michiel Perdeck
1996-11-03  0:00 ` Robert A Duff
1996-11-03  0:00 ` Laurent Guerby
1996-11-04  0:00   ` Do-While Jones
1996-11-06  0:00     ` Robert A Duff
1996-11-07  0:00       ` Tucker Taft
1996-11-08  0:00         ` Robert A Duff
1996-11-08  0:00       ` Robert Dewar
1996-11-09  0:00         ` Tucker Taft
     [not found]           ` <E0Mr58.D00@world.std.com>
1996-11-09  0:00             ` Robert Dewar
1996-11-04  0:00 ` Michel Gauthier [this message]
replies disabled

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