Problems when using Err.Raise in a public method of an activex 
Author Message
 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 ?

Thanks for your help



Mon, 02 Apr 2001 03:00:00 GMT  
 Problems when using Err.Raise in a public method of an activex

As soon as your Err.Raise instruction is executed, the on error event handler is called.  On Error Resume Next will simply execute the next instruction in line following where the error was found.  You need to use "On Error Goto ErrorHandler" to handle your error. If your error is non-crictical, you can still "resume next" within your error code.
This is a real quick and small example..............

public sub TESTSUB()
    on error goto TESTERR:

    code line 1
    code line 2
    err.raise xxxxxxxxxxxxx
    code line 4
    exit sub

TESTERR:
    select case err.number
        case is = ??        'critical error
            msgbox "xxxxxxxxxxxxxxx"            'Will exit the sub

        case is = ??        'non-critical error
            msgbox "xxxxxxxxxxxxx        'optional??
            RESUME NEXT                'will resume execution at code line 4
    end select
end sub

If ON ERROR GOTO TESTERR: is replaced with ON ERROR RESUME NEXT, code line 4 will IMMEDIATELY execute and no error will be called.

Hope this helps.

    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 ?

    Thanks for your help



Tue, 03 Apr 2001 03:00:00 GMT  
 Problems when using Err.Raise in a public method of an activex
Jenny,

I am pretty sure someone has answered this question for you already, but...

Think through what is happening when you put on error resume next. You are
telling it to ignore errors. No surprise then that the error doesn't get
raised.

The solution:

1. Raise the error in an errorhandler (ie. use On error goto ErrorHandler).
2. Use On error goto 0, which turns off error-handling (so the error will
not be ignored).

Also, it isn't well documented, but make sure that lErrorCode is greater
than 512.

Matthew



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 ?

Thanks for your help

----------



Thu, 05 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problems when using Err.Raise in a public method of an activex

2. Problems when using Err.Raise in a public method of an activex

3. using err.raise method, as to generate app error

4. Err.Raise in OLE Server EXE not raising error in calling program

5. Err.Raise - error not being re-raised all the way to top of the call stack

6. err.raise in ActiveX component - newbie

7. CDO Problem using the GetMessage method to find a message in a Public Folder

8. Problems with Err.Raise in a class module.

9. Problem with Err.Raise and ByRef output arguments.

10. Err.Raise Problem

11. Problem using and ACTIVEX method from ASP

12. Problem using and ACTIVEX method from ASP

 

 
Powered by phpBB® Forum Software