Forum Discussion
Philip_Baird
12 years agoCommunity Expert
Hi Frank, you are correct, Exception handling between Script Units is not supported and as far as I am aware, there is no way around this.
In your case, you could change ErrorChecker to accept a reference parameter and pass the local Err object from FileA to it, e.g.
'USEUNIT FileB
Sub MyFunction
on error resume next 'start local error catching
'raise a custom error
err.raise vbObjectError + 1, "MyFunction", "Customer error"
Log.Message( Err.Number) ' Logs -2147221503
ErrorChecker Err 'check for errors and handle them
Log.Message( Err.Number) ' Logs 0
on error goto 0 'stop local error catching
End Sub
Sub ErrorChecker( ByRef errObj )
If errObj.Number <> 0 Then
'handle the error
errObj.Clear
End If
End Sub
Hope this helps,
Phil