michaelslamet Posted January 27, 2014 Posted January 27, 2014 (edited) In code below, I try to capture an error that cause by .MoveNext It doesn't work because maybe .MoveNext doesn't generate @error. $SQLCode = "SELECT blabla;" $TableContents = _Query ($SQLInstance_Local, $SQLCode) If Not @error Then With $TableContents While Not .EOF ;doing something here .MoveNext If @error Then Msgbox(0,"Error","Server unreachable!") Exit EndIf WEnd EndWith EndIf How to capture the error WITHOUT using ObjEvent (eg: $objErr = ObjEvent("AutoIt.Error","MyErrFunc")) ? Edit: the reason I dont want to use $objErr = ObjEvent("AutoIt.Error","MyErrFunc") is because IE.au3 generate a lot of errors when the error handler is active so the script is pushed to exit. How to turn off the error handler just for IE.au3? Edited January 27, 2014 by michaelslamet
water Posted January 27, 2014 Posted January 27, 2014 Which version of AutoIt do you run? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
michaelslamet Posted January 27, 2014 Author Posted January 27, 2014 Which version of AutoIt do you run? Hi Water, I'm running 3.8.8.1 on WinXP and Win7
water Posted January 27, 2014 Posted January 27, 2014 With AutoIt > 3.3.8.1 the script no longer crashes when a COM error occurres. You simply check @error. So a COM error handler is only needed if you want to retrieve more detailed error information (true for IE UDF and ADO ...). My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
michaelslamet Posted January 27, 2014 Author Posted January 27, 2014 With AutoIt > 3.3.8.1 the script no longer crashes when a COM error occurres. You simply check @error. So a COM error handler is only needed if you want to retrieve more detailed error information (true for IE UDF and ADO ...). I'm not sure if I'm understand you. In this scenario, how to catch the error when --let say-- query all of the records and suddently the server is unreachable? $SQLCode = "SELECT blabla;" $TableContents = _Query ($SQLInstance_Local, $SQLCode) If Not @error Then With $TableContents While Not .EOF ;doing something here .MoveNext If @error Then Msgbox(0,"Error","Server unreachable!") Exit EndIf WEnd EndWith EndIf Register an error handler seems doesn't solve it, the error handler doesn't display anything when the connection is broken. Checking the @error seems not a solution too, because .movenext doesn't return any @error
water Posted January 27, 2014 Posted January 27, 2014 How do you now notice that an error occurred? Script crash, error message, @error is set ...? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
michaelslamet Posted January 29, 2014 Author Posted January 29, 2014 Water, Thanks for your help The error handler works great, seems just because I place it on the wrong place
water Posted January 30, 2014 Posted January 30, 2014 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now