General question on catching exceptions

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Eric Sabine (mopar41_at____ho_y_tmail.ScPoAmM)
Date: 05/18/04


Date: Tue, 18 May 2004 09:43:19 -0400

I built a generic exception handler form which allows the user to get
information from it, print it, email it, etc. for exceptions for which I
explicitly didn't handle in code, such as missing permissions on a stored
procedure, etc. I use this exception handler in all of my applications and
it can be called as simply as follows

try
    ...
catch ex as sqlexception
    ExceptionHandler(ex, otherData1, otherData2)
catch ex as exception
    ExceptionHandler(ex, otherData1, otherData2)
end try

As a habit, I tend to wrap every method and event within a try-catch block,
but now I am wondering if that is necessary. All of my apps start with Sub
Main which also contains a try-catch block that catches these 2 exceptions.
So if there isn't a specific exception within a method or event that I am
specifically testing for, or where I do something different that I've
already specified in Sub Main(), is it just a waste to catch an exception
there that I, by default, could already catch in Sub Main()?

Hope this makes sense.

Eric



Relevant Pages

  • Re: Question for Randy or Frank
    ... This is an HLA standard library facility. ... >> that you won't get under Windows. ... Then there's the "exception handling" approach to errors (which the HLA ... rather than solely "one big exception handler" wrapping the entire program ...
    (alt.lang.asm)
  • Re: Structured Exception Handling (was: Try Finally...)
    ... >> exception handlers and termination handlers. ... >> exception filtering, except clauses, and finally clauses, is up to ... > exception handler related to the stopping exception filter. ...
    (comp.lang.pascal.delphi.misc)
  • StackWalk behaviour
    ... I am adding an exception handler to certain of our build configurations ... actually dump the callstack for each thread. ... the second and third seemed to result in a valid callstack. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Practical error/exception handling...
    ... > try-except blocks until they reach the exception handler that really ... > If you have a catch-all exception handler, ... > the stack to the next exception handler. ... Raptor squirms in seat, ...
    (alt.comp.lang.borland-delphi)
  • Re: Try Finally...
    ... >> exception handler procedure was set in sysutils.pas. ... > none of which are provided by the current Delphi exception handlers. ... so you have no problem writing your own exception handler. ... exception handling right. ...
    (comp.lang.pascal.delphi.misc)