Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#3841 closed Bug (No Bug)

COM Error Handling

Reported by: kAnon Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description

Error handler does not work with array elements.

#include <StringConstants.au3>

test()

Func test()
    Local $oComError = ObjEvent('AutoIt.Error', onComError)
    #forceref $oComError

    Local $oObject
    Local $aoObjects[1]
    $oObject.TestComError() ; error handled
    $aoObjects[0].TestComError() ; error not handled
EndFunc   ;==>test

Func onComError($oComError)
    With $oComError
        ConsoleWrite(@ScriptName & ' (' & .ScriptLine & ') : ==> COM Error intercepted !' & @CRLF & _
                @TAB & '.Number:' & @TAB & @TAB & '0x' & Hex(.Number) & @CRLF & _
                @TAB & '.WinDescription:' & @TAB & StringStripWS(.WinDescription, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING, $STR_STRIPSPACES)) & @CRLF & _
                @TAB & '.Description:' & @TAB & @TAB & .Description & @CRLF & _
                @TAB & '.Source:' & @TAB & @TAB & .Source & @CRLF & _
                @TAB & '.HelpFile:' & @TAB & @TAB & .HelpFile & @CRLF & _
                @TAB & '.HelpContext:' & @TAB & @TAB & .HelpContext & @CRLF & _
                @TAB & '.LastDllError:' & @TAB & @TAB & .LastDllError & @CRLF & _
                @TAB & '.ScriptLine:' & @TAB & @TAB & .ScriptLine & @CRLF & _
                @TAB & '.RetCode:' & @TAB & @TAB & '0x' & Hex(.RetCode) & @CRLF & @CRLF)
        SetError(.Number)
    EndWith
EndFunc   ;==>onComError

Console output

... : ==> COM Error intercepted !
    .Number:         0x000000A9
    .WinDescription: Variable must be of type 'Object'.
    .Description:
    .Source:
    .HelpFile:
    .HelpContext:
    .LastDllError:   0
    .ScriptLine:     1
    .RetCode:        0x00000000

... (12) : ==> Variable must be of type "Object".:
$aoObjects[0].TestComError()
$aoObjects[0]^ ERROR

Windows 10 Pro 21H1 x64
AutoIt Version: 3.3.14.5 / 3.3.15.4

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by jchd18

The description is a little wrong: the issue arises only with an uninitialized variable in an array and TestComError applied to it.

The following works correctly, which is a more real-world situation. Non-objects variables can't invoke a COM error handler by themselves, so that IFAIK only the TestComError method can make this minor problem show up.

Func test()
    Local $oComError = ObjEvent('AutoIt.Error', onComError)
    #forceref $oComError

    Local $oObject = ObjCreate("shell.application")
    Local $aoObjects = [$oObject]
    $oObject.TestComError() ; error handled
    $aoObjects[0].TestComError() ; error not handled
EndFunc   ;==>test

comment:2 Changed 3 years ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

comment:3 Changed 3 years ago by kAnon

It's still inconvenient to work with arrays of objects. Why is the behavior different for an array cell and a regular variable?

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 closed 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.