Re: Common exception handling



On 26 Aug, 15:43, Adam Beneschan <a...@xxxxxxxxxx> wrote:
On Aug 26, 6:47 am, shaunpatter...@xxxxxxxxx wrote:

Yeah, it looks like the extra layer of exception handling is the only
way. I was hoping I could avoid that if possible.

No, I don't think it's the only way.  I'm surprised no one has
suggested this:

   exception
      when E : others =>
         Print_Test (Rec);
         declare
             use Ada.Exceptions;
         begin
             if Exception_Identity(E) = A'Identity then
                ... handling for A
             elsif Exception_Identity(E) = B'Identity then
                ... handling for B
             etc.
             else
                ... handling for other exceptions you didn't expect,
                ... but you certainly need to aware that it could
                ... happen
                raise;  --maybe
             end if;
         end;

                            -- Adam

Surely you missed a smiley off this suggestion!!! :-)

== Martin
.



Relevant Pages

  • Re: compilation problem with module function interface definition
    ... >> decimal floats start appearing, it would be wise for users to avoid ... > for numeric literals was a decimal KIND (as previously suggested ... I guess I sort of passed over that suggestion because I don't ...
    (comp.lang.fortran)
  • Re: Arguments problem repost
    ... your Date suggestion also solved my second worry. ... XXX.xls - 1st file overwrite current file name, ... following day and onward, how to avoid it overwrite the ...
    (microsoft.public.excel.programming)
  • Re: (OT) Singing my same old sad song.
    ... they avoid the full text of what has been written, and claim the NEED to drive to work, ignoring such things as car pooling, making fewer trips to the store, shopping closer to home, and otherwise cutting back on miles driven. ... Nobody has suggested that anyone STOP driving, yet most of the responses have been dished out as though that WERE the suggestion. ...
    (rec.outdoors.rv-travel)
  • Re: Bruising at injection sites?
    ... Grandpa Chuck wrote: ... Anyone have a suggestion on how to avoid the bruising? ...
    (alt.support.diabetes)
  • [PATCH] kmemleak: Rename kmemleak_panic to kmemleak_stop
    ... This is to avoid the confusion created by the "panic" word. ... (following Pekka's suggestion) ... struct early_log *log; ...
    (Linux-Kernel)