From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Common exception handling
Date: Tue, 26 Aug 2008 17:10:32 +0200
Date: 2008-08-26T17:10:33+02:00 [thread overview]
Message-ID: <3263z19x9l0r.1bbulsb9dbwjm.dlg@40tude.net> (raw)
In-Reply-To: ba811359-e5b7-4e06-90e6-479755d9d28c@25g2000prz.googlegroups.com
On Tue, 26 Aug 2008 07:43:20 -0700 (PDT), Adam Beneschan wrote:
> On Aug 26, 6:47 am, shaunpatter...@gmail.com 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;
Hmm, it looks quite ugly, IMO. Exception handler (case-like) is better
structured, cleaner, and possibly more efficient.
---------
If exceptions were first-class citizens allowed in case statements then:
exception
when E : others =>
Print_Test (Rec);
case E is -- This is not Ada, alas!
when A => ...
when B => ...
when others => ...
end case;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2008-08-26 15:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-26 12:17 Common exception handling shaunpatterson
2008-08-26 12:37 ` Ludovic Brenta
2008-08-26 12:39 ` Martin
2008-08-26 12:48 ` Ludovic Brenta
2008-08-26 12:58 ` Martin
2008-08-26 13:47 ` shaunpatterson
2008-08-26 14:43 ` Adam Beneschan
2008-08-26 15:10 ` Dmitry A. Kazakov [this message]
2008-08-26 16:49 ` Adam Beneschan
2008-08-26 19:14 ` Dmitry A. Kazakov
2008-08-26 20:22 ` Maciej Sobczak
2008-08-27 8:16 ` Dmitry A. Kazakov
2008-08-27 9:20 ` Georg Bauhaus
2008-08-29 8:32 ` Martin
2008-08-29 15:31 ` Adam Beneschan
2008-09-10 22:51 ` Martin
2008-09-11 14:57 ` Adam Beneschan
2008-08-26 15:18 ` Jean-Pierre Rosen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox