Re: Common exception handling



On Aug 26, 8:10 am, "Dmitry A. Kazakov" <mail...@xxxxxxxxxxxxxxxxx>
wrote:
On Tue, 26 Aug 2008 07:43:20 -0700 (PDT), Adam Beneschan 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;

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;

Maybe this use of CASE should be allowed, even if we don't go all the
way and make exceptions first-class entities in other ways. What does
anyone else think... would it be a worthwhile feature to propose
adding? Or is it just too "special" (if we added this, others would
ask, well why shouldn't we allow CASE on a string, or a record, or a
container, or just expand it using some user-specified relational
operator so that we can use it for everything...)?

-- Adam
.



Relevant Pages

  • Re: Error handling in VB6
    ... The VB syntax for catching and handling errors is definitely not ... exceptions thrown in Main, and in anything called from Main. ... OnError GoTo SomeErrHandler ... VB6 has no such thing as a global error handler. ...
    (microsoft.public.vb.general.discussion)
  • Re: File Descriptors
    ... At least one Tcl ... I think that depends somewhat one where you are coming to tcl/tk from. ... With regard to error handling in particular, ... Conditions under which exceptions occur ...
    (comp.lang.tcl)
  • Re: Practical error/exception handling...
    ... >> exceptions be iterated in order to get a better response. ... >> What I have done in the past is to have a database table of error codes ... >> error to a global error handling routine that can roll back transactions ... deal with a missing network connection or a file being locked when these ...
    (alt.comp.lang.borland-delphi)
  • Re: VB2008: Getting the System.Reflection.PropertyInfo from within a class property
    ... to get into Exception handling. ... MyClass is responsible for the data ... In case user input is required the the data is passed to a ... Stacktrace" in the case of handling exceptions. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Oh boy, how did we miss this...
    ... >This error seems to trigger SEH immediately, but no handler responded because I ... use the OS's own reporting mechanism in a way that was never intended (at ... There are several different error handling mechanisms in Windows... ... Structured Exceptions ...
    (comp.lang.pascal.delphi.misc)