Modify

Opened 4 years ago

Last modified 4 years ago

#3167 new Bug

COM Error Handler - not always fires event

Reported by: mLipok Owned by:
Milestone: Component: AutoIt
Version: 3.3.15.0 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

Discussion:
https://www.autoitscript.com/forum/topic/178424-com-error-handler-not-working-for-some-strange-reason/

Here is reproducer:

; Initialize COM error handler
$oErrorHandler = ObjEvent("AutoIt.Error", _ErrFunc)
Func _ErrFunc($oError)
    ConsoleWrite("!ERROR caught" & @CRLF)
EndFunc

; Create shell object
$oObj = ObjCreate("shell.application")

;The following line should trigger COM error handler (at the last dot).
$oObj.Windows().Item(666).bzzzzzzz

Here are some of my test results:

;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3.3.8.1\ ; NOTHING
;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_10_2\ ; !ERROR caught
;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_12_0\ ; !ERROR caught
;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_13_12\ ; NOTHING
;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_13_15\ ; BUG/ISSUE EXIST
;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_13_19\ ; BUG/ISSUE EXIST
;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3.3.15.0\ ; BUG/ISSUE EXIST

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by mLipok

  • Description modified (diff)

comment:2 Changed 4 years ago by Jpm

In fact

;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.8\3.3.8.1\install\		; not detected
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.10\3.3.10.2\install\	; OK
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.12\3.3.12.0\install\	; OK
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.0\install\	; OK
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.6\install\	; OK
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.7\install\	; not detected
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.9\install\	; not detected
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.12\install\	; not detected
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.13\install\	; Fatal Error
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.18\install\	; Fatal Error
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.13\3.3.13.21\install\	; Fatal Error
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.14\3.3.14.2\install\	; Fatal Error
;~ #AutoIt3Wrapper_Autoit3Dir=d:\AutoIt_Tags\3.3.15\3.3.15.0\install\	; Fatal Error

In fact it was OK even with the reference to an unknown function in 3.3.10 till 3.3.13.6
3.3.13.7 reintroduce the no detection as 3.3.8.1

Example()

Func Example()
	; Error monitoring. This will trap all COM errors while alive.
	; This particular object is declared as local, meaning after the function returns it will not exist.
	Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
	#forceref $oErrorHandler

; Create shell object
	Local $oObj = ObjCreate("shell.application")

	;The following line trigger COM error handler.
	$oObj.InvalidFunction()
	If @error Then
		ConsoleWrite("+COM Error Detected @error=0x" & Hex(@error) & @CRLF)
	Else
		ConsoleWrite("!COM Error Not Detected" & @CRLF)
	EndIf

	;The following line should trigger COM error handler (at the last dot).
	$oObj.Windows().Item(666).bzzzzzzz
	If @error Then
		ConsoleWrite("+COM Error Detected @error=0x" & Hex(@error) & @CRLF)
	Else
		ConsoleWrite("!COM Error Not Detected" & @CRLF)
	EndIf
EndFunc   ;==>Example

Func _ErrFunc($oError)
;~ 	#forceref $oError
    ConsoleWrite("+ERROR caught at ligne " & $oError.scriptline & " : " & StringTrimRight($oError.windescription, 2) & @CRLF)
;~ 	ConsoleWrite(@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)
EndFunc   ;==>_ErrFunc

comment:3 Changed 4 years ago by mLipok

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as new The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.