willwatters Posted October 22, 2004 Share Posted October 22, 2004 I want to incorporate error handling in my code. So when i perform an automatic task I want to know if any errors occured and if so log this to a file. For example if i auotmatically open up an application or do a task i want to know if an error was generated and if so write this to a log file. Thanks Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted October 22, 2004 Share Posted October 22, 2004 That depends on how the application you are automating shows errors. If it is a GUI application you can trap for an error window using the AdlibEnable() function. If it is a CLI application then you need to pipe the output to a text file and monitor the contents of the file. You may be able to use the Adlib to accomplish this also. *** Matt @ MPCS Link to comment Share on other sites More sharing options...
scriptkitty Posted October 22, 2004 Share Posted October 22, 2004 many programs will give you an exit code, or you may get an error window that pops up. You can make your script look for these windows, and record the exit codes (if program gives them), and check to see if the program did what it was suposed to (file check maybe?) Set your error text you want to $errorcheck and then Just use a simple FileWriteLine("myerror.log",$errorcheck) AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
willwatters Posted December 24, 2004 Author Share Posted December 24, 2004 (edited) For the AdlibEnable() function I have used the following at the start of my script: ;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc) AdlibEnable("myadlib") Func myadlib() If WinActive("Error") Then MsgBox(48, "Error Found", "Unexpected error occurred") Exit WinClose("BAJI/CACI Jury Instruction Selector for Windows") WinClose("Jury Instruction Selector") WinClose("New Instruction Set") WinClose("BAJI/CACI Jury Instruction Selector for Windows [instructions Not Saved]") EndIf EndFunc Will this work (check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc)) and is there any other code I need to enter here please? Is there also a way of capturing the type of error in order to display it in the MsgBox? Thanks for the great advice! Edited December 24, 2004 by willwatters Link to comment Share on other sites More sharing options...
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