I once had this problem in an earlier version of AutoIt, The problem was caused by the $oError not being an Objetc. If this situation Appears it cause Object failed when accessing $oError.scriptline ou any other propriety of $oError ant the Srcript is terminated The solution was to determine whether $oErro is an Object before mounting the error se the example below
; INTERCEPTOR Of COMError for IE ===========================================
Local $R = _IEErrorHandlerRegister("_ErrFunc")
If $R <> 1 Or @error Then MsgBox(0x40010,Default,'ERROR Executing: $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")')
Global $sCOMErr ; String with last Error
Global $oCOMError ; Objeto with last Error
Global $Trace = True ; Set to display the Error in the Console
; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
If Not IsObj($oError) Then ; This is nessesary to prevento the program crashing
ConsoleWrite("! ===================== _ErrFunc($oError) $oError Is Not Objeto ==========================================" & @LF)
Return
EndIf
$oCOMError = $oError ; Armazena uma Copia dos Erros
$sCOMErr = @ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
@TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
@TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
@TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
@TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
@TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
@TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
@TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
@TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
@TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF
If $Trace Then ConsoleWrite(@CRLF & @CRLF & "! ================= Object ERROR ==========================================================" & @CRLF & @CRLF & _
">" & StringReplace(StringReplace($sCOMErr,@CRLF & @CRLF,@CRLF,0,1),@CRLF,@CRLF & ">",0,1) & @CRLF & _
"! =========================================================================================" & @CRLF & @CRLF)
SetError($_IEStatus_ComError)
Return
EndFunc ;==>_ErrFunc
Another solution if you are using the AutoIt version 3.3.14.2 is to adjust the #Include <IE.au3> Func below added to row If Not IsObj ($ oCOMError) Then Return; IT can be invaluable because it can happen to $ oCOMError not be an object The doubt here is if indeed there was a COMError or not there was to have put q Return SetError ($_ IEStatus_ComError) rather than only Return if not Object
; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __IEInternalErrorHandler
; Description ...: to be called on error
; Author ........: Dale Hohm
; Modified ......:
; ===============================================================================================================================
Func __IEInternalErrorHandler($oCOMError)
If Not IsObj($oCOMError) Then Return ; ISSO É Nesessario pois pode acontecer de $oCOMError não ser um Objeto
If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then ConsoleWrite("--> " & __COMErrorFormating($oCOMError, "----> $IEComError") & @CRLF)
SetError($_IEStatus_ComError)
Return
EndFunc ;==>__IEInternalErrorHandle