Register and enable a user COM error handler
#include <IE.au3>
_IEErrorHandlerRegister([$s_functionName = "__IEInternalErrorHandler"])
| $s_functionName | [optional] String variable with the name of a user-defined COM error handler, defaults to the internal COM error handler in this UDF |
| Success: | Returns 1 |
| Failure: | Returns 0 and sets @ERROR |
| @Error: | 0 ($_IEStatus_Success) = No Error |
| 1 ($_IEStatus_GeneralError) = General Error | |
| @Extended: | Contains invalid parameter number |
; *******************************************************
; Example 1 - Register and later deregister a custom and the default IE.au3 error handler
; *******************************************************
#include <IE.au3>
; Register a customer error handler
_IEErrorHandlerRegister("MyErrFunc")
; Do something
; Deregister the customer error handler
_IEErrorHandlerDeRegister()
; Do something else
; Register the default IE.au3 COM Error Handler
_IEErrorHandlerRegister()
; Do more work
Exit
Func MyErrFunc()
; Important: the error object variable MUST be named $oIEErrorHandler
Local $ErrorScriptline = $oIEErrorHandler.scriptline
Local $ErrorNumber = $oIEErrorHandler.number
Local $ErrorNumberHex = Hex($oIEErrorHandler.number, 8)
Local $ErrorDescription = StringStripWS($oIEErrorHandler.description, 2)
Local $ErrorWinDescription = StringStripWS($oIEErrorHandler.WinDescription, 2)
Local $ErrorSource = $oIEErrorHandler.Source
Local $ErrorHelpFile = $oIEErrorHandler.HelpFile
Local $ErrorHelpContext = $oIEErrorHandler.HelpContext
Local $ErrorLastDllError = $oIEErrorHandler.LastDllError
Local $ErrorOutput = ""
$ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR
$ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR
$ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR
$ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR
$ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR
$ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR
$ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR
$ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR
$ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR
$ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError
MsgBox(0, "COM Error", $ErrorOutput)
SetError(1)
Return
EndFunc ;==>MyErrFunc