
Problems when using Err.Raise in a public method of an activex
Hi
I am having trouble when using Err.Raise in a public method of an activex.
I am using "On Error Resume Next" to perform inline error checking. When
an error occurs I am raising an error with :
Err.Raise vbObjectError+ lErrorCode,"MyModule","MyFunction"
The amazing thing is that the client (an ASP page or a vb client) that
creates the object and invokes my method never receives a valid Err object.
In fact it is empty.
If I replace the "On Error Resume Next" with "On Error Goto ErrorHandler"
and if I raise an error with the same manner it will work !!!!
What I am doing wrong ?
Nothing. That's the way it is supposed to work. The only place you should be using On Error Resume Next is in situations where you're not going to handle the error for some reason, or if there is an error you are going to just abort the process completely. In other words, you just check for Err.Number being greater than zero, and if so you abort. Otherwise you should have an error handling routine, because that's the way VB was designed to handle errors.
jdm