Re: Error Handling

If you put an On Error in a Sub Main then it will catch most (unhandled-)
exceptions, except those inside event handlers. These are not propagated
back down the stack beyond the start of the event, presumable because
there's no way of knowing exactly which previous handler would see it. This
is why Ken suggested an error trap in each event handler.

Otherwise, look for examples of SetUnhandledExceptionFilter.When all
frame-based exception handlers have been tried, this is the last-chance

You can also look at exceptions *before* any of the frame-based handlers
using AddVectoredExceptionHandler, although that doesn't exist in W2K and
below. A vectored exception handler gets called before any stack-based
handlers. Things like the debugger use these as they get called before any
handlers in the VB run-time or your own code. Such handlers are usually
non-intrusive -- meaning they see but don't actually "handle" the exceptions
themselves -- otherwise it could prevent other code working normally

Tony Proctor

"Jérémie Gent" <jer_kjr@xxxxxxxxxxx> wrote in message
Hi there

Not sure if I should ask this here but it's worth a try
Is there really no way to set an Error Handling System for a whole
without having to put 'On Error Goto ... ' + Error handler locally in each
procedure ?
Maybe some process could watch the Err object and fire an event when its
content changes ...
I don't really care if my application crashes, but I would need to know
the error number / description was and in which procedure (line number if
possible) the problem occured. Logging that info into a file would be

Thanks in advance if you know something about that or have any idea.



Relevant Pages

  • Re: Comparison with False - something I dont understand
    ... built-in exceptions which are thrown by library functions to follow its ... to place the error handling code wherever it makes sense to do so. ... and in the bounderies between subsystems. ... it up to the error handlers on top of the boundry. ...
  • Re: Exceptions
    ... programming with functions that return objects with run-time ... easily use error codes and must use exceptions to signal problems. ... handlers spoiling each and other program block. ... middle layer that reuses those primitives, ...
  • Re: Exceptions
    ... I'm not sure if Dmitry really wants answers to his questions below ... But as I said, I reuse exceptions much. ... But my feeling is that at least half of the handlers are ... exceptions propagate unhandled. ...
  • Re: Exceptions
    ... Such functions cannot easily use error codes and must use exceptions to signal problems. ... handlers at all and thus propagate all exceptions raised in them or in their callees. ... I think all subprograms would need contracts, not just the few subprograms that have exception handlers. ... The contract has to be in the subprogram declaration, while the presence or absence of exception handlers is a property of the body. ...
  • Re: Exceptions
    ... propagating it further? ... So you do not need to place any handlers in 9/10 subprograms. ... 'How does a language feature affect programs?' ... contracted exceptions will sufficiently improve quality of Ada programs. ...