Global Error Handler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Timh Bergström

    Global Error Handler

    Hi all!

    Can i do a global "on error" statement for all forms and modules instead of
    having "on error goto ErrHand" in each sub/function?
    The error should be catched to another form there the error is summarized
    and reported to the user and the user can send the error
    to me directly? Any help or example is greatly appreciated.

    --
    Vänligen,
    Timh Bergström


  • Asperamanca

    #2
    Re: Global Error Handler

    "Timh Bergström" <timh.b@telia.c om> wrote in message news:<CJ41b.207 56$mU6.31749@ne wsb.telia.net>. ..[color=blue]
    > Hi all!
    >
    > Can i do a global "on error" statement for all forms and modules instead of
    > having "on error goto ErrHand" in each sub/function?
    > The error should be catched to another form there the error is summarized
    > and reported to the user and the user can send the error
    > to me directly? Any help or example is greatly appreciated.[/color]

    As far as I know, this is not possible. It would be so nice...
    The best I can think of is to write a function that summarizes the
    error and reports it, and call it from the error handler of every
    function in your project. Better still, Build in a Err.Raise into the
    subs and functions within modules and class modules, and call the
    reporting function only from subs and functions whithin forms and user
    controls that are directly invoced (events and public functions). That
    way you can even collect a call stack.
    It's a lot of handwork though. But there are some programs that work
    as add-ins to VB and can add error handlers. It's not even so
    difficult to write such a thing yourself: All you need is to find the
    head of a procedure (Private/Public Sub/Function/Property ...), add
    the On Error statement, then find the end (End Sub/Function/Propert)
    and add the handler (without forgetting the Exit
    Sub/Function/Property)

    That's more or less what I did...until I realized that it's more work
    than what I save during error analysis. Depends on how your
    application is deployed, naturally. Now, I only add error handlers to
    critical functions, those where I deem an error to be "realistic" .

    Robert

    Comment

    Working...