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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bfe6c77b20fb48c4 X-Google-Attributes: gid103376,public From: Florian Weimer Subject: Re: Exception Save_Occurence Usage Date: 2000/02/15 Message-ID: <87zot2c07u.fsf@deneb.cygnus.argh.org>#1/1 X-Deja-AN: 586039329 References: <38A83769.13E22D48@res.raytheon.com> Mail-Copies-To: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@cygnus.argh.org X-Trace: deneb.cygnus.argh.org 950605029 18444 192.168.1.2 (15 Feb 2000 08:57:09 GMT) Organization: Penguin on board User-Agent: Gnus/5.0804 (Gnus v5.8.4) Emacs/20.4 Mime-Version: 1.0 Reply-To: Florian Weimer NNTP-Posting-Date: 15 Feb 2000 08:57:09 GMT Newsgroups: comp.lang.ada Date: 2000-02-15T08:57:09+00:00 List-Id: John J Cupak Jr 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;