Is On Error all it is cracked up to be? Or am I using it wrong?
I have a script with an 'On Error go to Error_Handler" call in it:
SQALogMessage sqaFail, "oops", ""
call ieCloseBrowser ' Close all IE browsers
I invoke it on purpose my trying to click on a non-existent button (as I'm currently testing out the code).
So, I'm running this via Test Manager in batch mode, and when it gets to the line to click on the non-existent button, it never calls the Error_Handler. Robot's playback reacts based on what I set it under Tools\GUI Playback Options: 'Continue execution', 'Skip current script', or 'Abort playback'.
What I was looking for was the script to trap the error (since I have "On Error goto Error_Handler" as the first line in the script, it should catch everything), and then execute the code within the Error_Handler goto piece of code.
After reading the DeveloperWorks forums, I found some old messages explaining this; seems like once something fails at runtime, there's no way for the code to jump to the error handler code.
So, my next question would be, how would I be able to run "clean up" code in situations like this? i.e. to close IE browsers, unlock DB records, etc.
On error can be used on errors which are listed in help "On Error"->Overview->Trappable errors.
So if something fails and you want to close all IE browsers then e.g. call a subroutine which does it.
If you want to give somebody a fish, you'll do better if you teach him how to catch it.