Forum Discussion

SushantNfl's avatar
SushantNfl
Occasional Contributor
6 years ago

How to prevent error handler to go back to the error line after executing GeneralEvents_OnLogError?

Hi,

 

For handling UI errors, I am using GeneralEvents_OnLogError which again goes to the error line after executing its definition.

But I don't want it to return to the original error source.

Instead I want that the script execution should stop after execution of GeneralEvents_OnLogError is complete.

How can I achieve this?

 

Thanks in advance.

6 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

     

    Option#1:

    Enable the Stop on Error option in the Tools > Current Project Properties.

     

    Option #2:

    Use Runner.Stop() method inside the GeneralEvents_OnLogError function.

    • SushantNfl's avatar
      SushantNfl
      Occasional Contributor

      Thanks Shankar.

       

      Well I actually have a different requirement.

      I have a list of data for which the same set of actions needs to be performed.

      Whenever an UI error occurs for one instance, I need to close the software -> Relaunch it -> then start the process for the next item in the list.

      I am maintaining list index globally so thats not a problem.

      I tried incrementing index in onlogerror method and called the main function again (although its not the correct approach) and runner.stop() after that.

       

      index=0
      
      def main():
      	global index
      	list = ["A","b","c"]
      	launchApplication()
      	
      	while index<len(list):
      		performActions(list(index))  #this code will throw UI errors
      		
      		
      def GeneralEvents_OnLogError(Object Sender, EventArgs logParam):
      	global index
      	index = index + 1
      	closeApplication()
      	main()    
      	Runner.Stop()

      The issue here is although the error instance is skipped and the next set of items are executed, the code after executing main() (underlined) doesn't stop and goes back to the line where error came up first.

       

       

       

      • shankar_r's avatar
        shankar_r
        Community Hero

        This can be a recursive call.

         

        Instead of using OnlogError event handler, you try like below.

        I'm not python/delphi scripter.

        Pseudo:

          

         index=0
        
        def main():
        	global index
        	list = ["A","b","c"]
        	launchApplication()
        	
        	while index<len(list):
        		if ! performActions(list(index))   #perfornActions should have return value as true or false
                         #do the relaunch and increment