I am using this piece of code in my project wherein I am supposed to throw a specific exception based on what activity failed to execute.
There are another 15-20 such clicks / select item activities used in my project (so I could not add try catch-around every other activity).
The bot is supposed to throw the exception in the following manner-
Failed to select “Months” at Select term- Moths (Select term- Moths is the activity name in the snapshot attached).
Could not find UI element corresponding to- Type term (Type term is the activity name in the snapshot attached)
I tried using exception.source and exception.message but it is not giving the expected results.
Instead it is showing everything except the name of the activity which failed.
@ChagantiAkhil - Hi, thank you for your reply.
I tried that, but it is not feasible to add a custom message for all 15/20 activities, so I am just looking for some way by using which we can get the activity name so that we can throw some generic exception like- system exception at - Select term- Moths (activity name)
Rename all the activities and add a try catch to whole workflow and in the catch block do a rethrow. In this case exception.Source + exception.Message - should give an output with activity name and selector failure message
@ChagantiAkhil - Hi, I tried this, but it it did not work. Anyways, thanks for your response, please let me know if there is any other way to achieve this.
Looking at the message - the activity name is getting referred to Try Catch. So, before rethrow add a log to see the exception as exception.source + exception.message
Hi @supermanPunch - I tried this but it seems exception.Data(“FaultedDetails”) is not containg any data which is causing little issue.
Also, I am adding this to the workflow so as to throw an exception which will clearly state activity name which failed, I can’t have try catch around each activity as I have another 15- 20 activities which might fail, so adding try catches and throws will make my code complicated.
Hope it answers your question!
Thanks!!
You may refer to the screenshot below for further reference: