* Exception Save_Occurence Usage
@ 2000-02-14 0:00 John J Cupak Jr
2000-02-15 0:00 ` Jim Rogers
2000-02-15 0:00 ` Florian Weimer
0 siblings, 2 replies; 4+ messages in thread
From: John J Cupak Jr @ 2000-02-14 0:00 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
Oh, Ada Gurus:
Does anyone have an example of how to use the
Ada.Exceptions.Save_Occurence function/procedure and the corresponding
Reraise_Occurence procedure? Syntax is easy to understand, semantics
takes a bit longer.
Neither the RM95 or the Ada 95 Rationale are really helpful in this
area.
Thanks in advance,
John
[-- Attachment #2: Card for John J Cupak Jr --]
[-- Type: text/x-vcard, Size: 364 bytes --]
begin:vcard
n:Cupak Jr;John J
tel;fax:978.858.4336
tel;work:978.858.1222
x-mozilla-html:TRUE
org:Raytheon Company;Northeast Software Training
version:2.1
email;internet:John_J_Cupak@res.raytheon.com
title:Software Engineering Instructor
adr;quoted-printable:;;50 Apple Hill Road=0D=0AT3MN35;Tewksbury;MA;01876;USA
x-mozilla-cpt:;9904
fn:John J Cupak Jr
end:vcard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Exception Save_Occurence Usage
2000-02-14 0:00 Exception Save_Occurence Usage John J Cupak Jr
@ 2000-02-15 0:00 ` Jim Rogers
2000-02-15 0:00 ` John J Cupak Jr
2000-02-15 0:00 ` Florian Weimer
1 sibling, 1 reply; 4+ messages in thread
From: Jim Rogers @ 2000-02-15 0:00 UTC (permalink / raw)
This issue is explained on page 652 of "Ada as a Second Language".
Procedure Save_Occurrence is used to make a copy of an
Exception_Occurrence so that the occurrence can be referred to later,
possibly at some other place in the program, even after the original
exception occurrence is no longer active.
--
Jim Rogers
Colorado Springs, Colorado USA
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Exception Save_Occurence Usage
2000-02-14 0:00 Exception Save_Occurence Usage John J Cupak Jr
2000-02-15 0:00 ` Jim Rogers
@ 2000-02-15 0:00 ` Florian Weimer
1 sibling, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2000-02-15 0:00 UTC (permalink / raw)
John J Cupak Jr <John_J_Cupak@res.raytheon.com> writes:
> Does anyone have an example of how to use the
> Ada.Exceptions.Save_Occurence function/procedure and the corresponding
> Reraise_Occurence procedure? Syntax is easy to understand, semantics
> takes a bit longer.
You can use them to promote exceptions across tasks. (Disclaimer: I
don't know whether this is politically correct usage of this
subprograms or brutal abuse.)
task type Feeder is
...
entry Get_Exception (E : out Exception_Occurrence;
Error : out POSIX.Error_Code);
-- Retrieves information about the error status of the task.
-- ... If no exception was raised, E is
-- Null_Occurrence. If no POSIX_Error exception was raised, Error is
-- POSIX.No_Error.
end Feeder;
task body Feeder is
...
Excep : Exception_Occurrence;
Err : POSIX.Error_Code := POSIX.No_Error;
begin
...
begin
...
exception
when E : others =>
if Exception_Identity (E) = POSIX.POSIX_Error'Identity then
Err := POSIX.Get_Error_Code;
end if;
Save_Occurrence (Target => Excep, Source => E);
end;
select
accept Get_Exception (E : out Exception_Occurrence;
Error : out POSIX.Error_Code) do
Save_Occurrence (Target => E, Source => Excep);
Error := Err;
end Get_Exception;
or
terminate;
end select;
end Feeder;
Feeders : array (Streams'Range) of Feeder;
EO : Exception_Occurrence;
Error : POSIX.Error_Code;
begin
...
for I in Feeders'Range loop
Feeders (I).Get_Exception (EO, Error);
-- The following operations do nothing if no exception occured in the
-- task.
if Error /= POSIX.No_Error then
POSIX.Set_Error_Code (Error);
end if;
Reraise_Occurrence (EO);
end loop;
end Feed;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2000-02-15 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-14 0:00 Exception Save_Occurence Usage John J Cupak Jr
2000-02-15 0:00 ` Jim Rogers
2000-02-15 0:00 ` John J Cupak Jr
2000-02-15 0:00 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox