-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhanced error handling with error(True) to raise exception on error [done] #299
Comments
Between the 2 ideas of having a function hook or raising exception for user-handling with try-catch, I would think the 2nd method is more accessible to users (more commonly known design pattern), and also gives more flexibility what to be done (calling some user-defined function, or do something else depending on the section of the script). |
Done in v1.47 and available with To handle errors during automation, use error(True) and Python try-except
r.error(True)
try:
r.click('element 1')
r.dclick('element 2')
r.type('element 3', 'abc')
except Exception as e:
print(e) # show specific error message
# do something to handle that error
r.error(True)
try:
r.click('element 1')
r.dclick('element 2')
r.type('element 3', 'abc')
except:
# the step that failed is not known
# do something to deal with error PS - default setting on initialising is error(False), so Python exceptions will not be raised on error |
user query from Telegram group chat on function hook error handling - https://t.me/rpa_chat/5886
Thanks for raising this! i open a new issue to explore this - #299
Will take some time, because I maintain the Python version in my personal free time. There are generally 2 ideas, 1 is a function hook. 1 is an option to raise error so that users can do a try-catch design.
For the time being, you can do -
Above works because each function call will return True or False depending on whether it is successful.
You can also split into multiple lines if you want the Python script to be neater -
The text was updated successfully, but these errors were encountered: