Re: HOWTO: Re-raise an error?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Ian Boyd wrote:
Before you re-raise the error, make sure 'On Error Resume Next' is no
longer in effect...

On Error GoTo 0
Err.Raise Number, Source, Description, Helpfile, HelpContext

...otherwise you will simply throw the error back at yourself.

If Err.Number <> 0 Then
On Error Goto 0
Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile,
Err.HelpContext
End If

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Err.Raise'


What else you got?

On Error Resume Next
x = 1/0

If Err.Number <> 0 Then
Dim ErrNumber : ErrNumber = Err.Number
Dim ErrDescription : ErrDescription = Err.Description
On Error GoTo 0
Err.Raise 666, "Source is me", ErrNumber & " : " & ErrDescription
End If


--
Michael Harris
Microsoft MVP Scripting


.