Jump to content

Basic Error handling


Recommended Posts

I am using $oTable = _IETableGetCollection($oIE, 1) in a loop every hour and writing data to a text file.  Occasionally my script will error out with the following...

It looks to me that it has an issue reading the table.  So I basically just want to ignore the error and try again.  Maybe a do-until makes sense?

 

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Scripts\Script.au3"    
"C:\Program Files\AutoIt3\Include\IE.au3" (1508) : ==> The requested action with this object has failed.:
Case $iIndex > -1 And $iIndex < $oObject.document.GetElementsByTagName("table").length
Case $iIndex > -1 A
nd $iIndex < $oObject.document^ ERROR
>Exit code: 1    Time: 83.41

Link to comment
Share on other sites

I changed it to....

DO

Sleep (500)
Local $oTable = _IETableGetCollection($oIE, 1)
Local $aTableData = _IETableWriteToArray($oTable)
Until IsArray($atabledata)

 

But I still feel like if that line in the Include errors out that it will throw an exception and stop the script

 

EDIT:  Yes indeed it does.  For that reason, I do not think @error would solve this for me either

Edited by wisem2540
Link to comment
Share on other sites

Guys,

I am already using a do-until as noted (rather than contiueloop) and its still not functioning.  I changed the script to a continuous loop with a brief pause for testing.  It runs a few dozen times before erroring, so I do not think this is an IE settings issue.  Since the error is happening inside the IE.au3 include, I believe these options are missing the mark.  I remember building an error handling function some time ago, but I do not remember how I did it

Edited by wisem2540
Link to comment
Share on other sites

Add in an error handler.  sometimes the dom object is inaccessible, and then when you try to get a property or child object, the script will blow up.   _ieerrorhandlerregister, or something like that.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

there is a possibility that the ie library needs fixing.It's also hard to say what stops your script without testing the script yourself.I realize this is more like workaround than solution however it might do the job.You can spawn a bat script to constantly monitor if your app process is alive.If not,then runs compiled script once more.

Link to comment
Share on other sites

I agree.   there should be error handling in the ie functions validating objects prior to diving into them.   but the workaround is to turn on the COM error handler as I mentioned

 

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

37 minutes ago, jdelaney said:

Add in an error handler.  sometimes the dom object is inaccessible, and then when you try to get a property or child object, the script will blow up.   _ieerrorhandlerregister, or something like that.

I did find this via a google search and I am experimenting with it now.  It should be enough for me to just call an empty function right?  Assuming that I wish to do nothing but ignore the error.  In theory, my do-until loop would handle everything

 

EDIT:  Closer, but no matter what I try, I continue to see this in the console and the script crashes.  But it seems to be capturing the error at least

 

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Scripts\xxx.au3"    
--> IE.au3 T3.0-2 Warning from function _IETableGetCollection, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IETableWriteToArray, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-2 Warning from function _IETableGetCollection, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IETableWriteToArray, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-2 Warning from function _IETableGetCollection, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IETableWriteToArray, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-2 Warning from function _IETableGetCollection, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IETableWriteToArray, $_IESTATUS_InvalidDataType
>Exit code: 3221225477    Time: 253.5
 

Edited by wisem2540
Link to comment
Share on other sites

Looks like it broke out of the loop.  Are you sure the script didn't eventually find the table?  Add in some consolewrite for debugging.

Need to see the script to know for sure.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...