Need help on how to get a activity name which failed during execution

Hi,

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-

  1. Failed to select “Months” at Select term- Moths (Select term- Moths is the activity name in the snapshot attached).
  2. 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. :frowning:
Instead it is showing everything except the name of the activity which failed. :sweat_smile:

Can someone please help me with this issue?

Any help is highly appreciated! :pray: :pray:
TIA!

image

1 Like

Hi,

If these activities are in Try/Catch - use a rethrow in the catch block. If you need a custom message, use a message inside throw

@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. :frowning_face: Anyways, thanks for your response, please let me know if there is any other way to achieve this.

If possible, Can you add a screenshot or a message on how you are getting the exception messages in the output panel?

@ChagantiAkhil- Hi, sure, please refer to the screenshot below:

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

I tried that as well, but it did not show any activity name there. :sweat_smile:

Hi @Sameer_Walimbe ,

Could you check the below post :

1 Like

Thank you @supermanPunch, I’ll try this and will let you know :slightly_smiling_face:

1 Like

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. :sweat_smile:
Hope it answers your question! :slight_smile:
Thanks!!

You may refer to the screenshot below for further reference:

Yes, for me “exception.Data(“FaultedDetails”)” is also not containing the info that it should contain.
I’m guessing is a bug, because it worked fine in previous UiPath versions.