Iczer

Com error in presence ComErrorHandler

6 posts in this topic

I have some script with ComErrorHandler, but i still sometime get fatal com errors. Why its happen? How i can counter this "The requested action with this object has failed" com error?

if i restart script error do not happen.

"E:\Some folder\Some script.au3" (1264) : ==> The requested action with this object has failed.:
$sVar = $oIE.document.body.getElementsByTagName("table").item(0).getElementsByTagName("td").item(0).getElementsByTagName("a").item(1).innerText
$sVar = $oIE.document.body.getElementsByTagName("table").item(0)^ ERROR

Com Error Handler :

Global $__ComErrorHandler = ObjEvent("AutoIt.Error", "Template_COMErrFunc")

;==============================================================
Func Template_COMErrFunc()
    Return Call("ComErrorHandlerFunction",$__ComErrorHandler)
EndFunc
;==============================================================
Func ComErrorHandlerFunction($errorEvent)
    If IsObj($errorEvent) Then

        ConsoleWrite("!--> DeluxeComErrorHandler: COM Error Encountered in " & @ScriptName & @CR)
        ConsoleWrite("----> Scriptline = " & $errorEvent.scriptline & @CR)
        ConsoleWrite("----> Number Hex = " & Hex($errorEvent.number, 8) & @CR)
        ConsoleWrite("----> Number = " & $errorEvent.number & @CR)
        ConsoleWrite("----> Win Description = " & StringStripWS($errorEvent.WinDescription, 2) & @CR)
        ConsoleWrite("----> Description = " & StringStripWS($errorEvent.description, 2) & @CR)
        ConsoleWrite("----> Source = " & $errorEvent.Source & @CR)
        ConsoleWrite("----> Help File = " & $errorEvent.HelpFile & @CR)
        ConsoleWrite("----> Help Context = " & $errorEvent.HelpContext & @CR)
        ConsoleWrite("----> Last Dll Error = " & $errorEvent.LastDllError & @crlf)
        ConsoleWrite("----> Last Dll Error = " & $errorEvent.ScriptName & @crlf)

        Local $HexNumber = Hex($errorEvent.number, 8)
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc
;==============================================================

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello.

I have some script with ComErrorHandler, but i still sometime get fatal com errors. Why its happen? How i can counter this "The requested action with this object has failed" com error?

if i restart script error do not happen.

"E:\Some folder\Some script.au3" (1264) : ==> The requested action with this object has failed.:
$sVar = $oIE.document.body.getElementsByTagName("table").item(0).getElementsByTagName("td").item(0).getElementsByTagName("a").item(1).innerText

This element expression is too long.

Try like this:

 

Local $oTables_coll = $oIE.document.body.getElementsByTagName("table")
If @error Then
    ;...
Else
    If $oTables_coll.length > 0 Then
        Local $oTDs_coll = $oTables_coll.item(0).getElementsByTagName("td")
        If @error Then
            ;...
        Else
            Local $oTagA_Cols = $oTDs_coll.item(0).getElementsByTagName("a")
            If @error Then
                ;...
            Else
                MsgBox(0, '', $oTagA_Cols.item(1).innerText)
            EndIf
        EndIf

    EndIf
EndIf

 

EDIT:

just you must do it STEP BY STEP with checking @error 

 

mLipok

Edited by mLipok
element >> expression

ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

here you have some imp (duplicated description):

ConsoleWrite("----> Last Dll Error = " & $errorEvent.LastDllError & @crlf)
        ConsoleWrite("----> Last Dll Error = " & $errorEvent.ScriptName & @crlf)

 

 

This is realy not needed:

Local $HexNumber = Hex($errorEvent.number, 8)
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0

unless you are doing it for your own purposes, because AutoIt does not need it.


ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

thanks, i will try something like that:

Local $oTables_coll = $oIE.document.body.getElementsByTagName("table")
If (Not @error) And ($oTables_coll.length > 0) Then
    Local $oTDs_coll = $oTables_coll.item(0).getElementsByTagName("td")
    If (Not @error) And ($oTDs_coll.length > 0) Then
        Local $oTagA_Cols = $oTDs_coll.item(0).getElementsByTagName("a")
        If (Not @error) And ($oTagA_Cols.length > 1) Then
            MsgBox(0, '', $oTagA_Cols.item(1).innerText)
        EndIf
    EndIf
EndIf

but isn't AutoIt also execute this long string step by step? ComErrorHandler should work on every step i think...

Share this post


Link to post
Share on other sites

I'm not sure, but this is good question to get answer and put it to the HelpFile.
I hope @Jon answer on your question.

 

cheers,

mLipok


ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

For reference:

I think you would be intrested to look here:

 

ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now