How to handle error exception

I parse data from web site. Some time the data doesn’t exist on the page. I could set “continue on error” but I would like to implement next branch of the algorithm (if error then). Do we have something like this.
How to implement this logic
IF datanotexist THEN

Hi @gotsdanker, welcome to the Community.

You can use the Try Catch activity for this. Place the code that you feel might error out in the Try block & keep the set of actions that you need to perform only if the error occurs in the Catch block. Then you can keep the common activities for both error & non-error scenarios in the Finally block.

Hope this helps,
Best Regards.

is it relevant to StudioX, community version?

@gotsdanker

Yes, it is. You can use the Try Catch in the StudioX when you filter ‘Show Developer’ option:

image

Best Regards.

@gotsdanker

Welcome to the community

You can actually use check app state activity which is more proactive approach …which will check for the existance of the data or element …it would by default give to two branches one for element appears and one for element missing

https://docs.uipath.com/activities/docs/n-check-state

Hope this helps

Cheers

Hi @gotsdanker

you can use the “Element Exists” activity along with the “If” activity. Here’s a step-by-step guide:

  1. Use the “Element Exists” activity to check if the element representing the data you are looking for exists on the web page. Configure the activity as follows:
  • Set the “Selector” property to identify the element on the web page.
  • Set the “TimeoutMS” property to an appropriate value to wait for the element to appear. You can specify a reasonable timeout to avoid waiting indefinitely.
  1. Add an “If” activity to create the logic for handling the presence or absence of the data. The condition for the “If” activity should be the output of the “Element Exists” activity. Configure the “If” activity as follows:
  • Set the “Condition” property to the output variable of the “Element Exists” activity.
  1. Inside the “Then” branch of the “If” activity, add the actions you want to perform when the data exists on the web page.
  2. Inside the “Else” branch of the “If” activity, add the actions you want to perform when the data doesn’t exist on the web page. This is where you can implement the next branch of the algorithm.

Thanks!!