cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
Occasional Contributor

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 6
Highlighted
Community Hero

Re: How to prevent error handler to go back to the error line after executing GeneralEvents_OnLogErr

 

Option#1:

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

 

stoponerror.png

Option #2:

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


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

Highlighted
Occasional Contributor

Re: How to prevent error handler to go back to the error line after executing GeneralEvents_OnLogErr

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.

 

 

 

Highlighted
Community Hero

Re: How to prevent error handler to go back to the error line after executing GeneralEvents_OnLogErr

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 
                  

  


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

Highlighted
Occasional Contributor

Re: How to prevent error handler to go back to the error line after executing GeneralEvents_OnLogErr

Got your point but it won't help.

If onlogerror is removed and Stop on error is unchecked (which is definitely required to continue the script execution), all the statements in performActions will be executed even if error come up on some line.

This is very risky considering the fact that a previous step wasn't performed correctly.

 

I need something like continue which can be used to skip the next steps for that iteration and start the next iteration of the loop whenever there is an UI error.

 

Highlighted
Community Hero

Re: How to prevent error handler to go back to the error line after executing GeneralEvents_OnLogErr

You have control over performActions function, you will be able to decide when a failure comes, I would suggest making changes in performActions to solve your scenario.

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

Highlighted
Occasional Contributor

Re: How to prevent error handler to go back to the error line after executing GeneralEvents_OnLogErr

Well python errors are well under control, but for UI errors, I was relying on GeneralEvents_OnLogError since Ui errors can either be controlled by stop on error setting or onlogerror method. Thats where I am stuck.

 

Anyways Thanks for your help. 🙂

If you have any other clue please let me know.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors