How to create business exceptions and follow an exception workflow/path?

Can someone provide me with resources to learn how to create and use business exceptions or explain to me how I can do this. In my current automation, I want my bot mark the work item as an exception when there are business exceptions by following my exception work flow path and not end process or proceed with the happy path flow.

thanks

1 Like

no worries
this would help you for sure on how to handle this
i would go with @loginerror point in this

Cheers @happygal321

Are there any examples of business exceptions workflows you can provide?

2 Likes

we got specific assignments in level 3 in uipath academy buddy
Kindly have a viw on it which will give you more insights
https://academy.uipath.com

kindly let know for any queries or clarification
Cheers @happygal321

1 Like

Good evening @happygal321

If you want to take action immediately on business exceptions, you can also use Try-Catch blocks.

These will allow you to specify which actions to take when specific exceptions happen.

@chenderson i dont understand how to use the try catch activity.

i currently have a for-each loop that is looping through all the dates in a collection (dynamic list). In the body of the for-loop i have an if/else activity. the if/else checks each date’s status and compares it to the current status. if it doesnt match, it should be marked as an exception and if it does match, then it will proceed to the next date and check. How would i put this into the try-catch? when it is exception out, i would like it to follow an exception workflow i have created. I dont want it to terminate the process completely like when using the “terminate workflow” activity. It should not continue to loop as soon as one of the date’s current status doesnt match the current status, and then proceed to follow the exception workflow.

Would i put the ‘Then’ sequence in the the Try section, and put a Break activity in the Catch section, and the Exception workflow in the Finally section? What about the ‘Else sequence’? does that need to go into the try catch?

When i tried the above approach, the break doesnt seem to do anything. It shows the message i put “mark as exception” (in my catch block), but then it continues to the next date, even though it shouldnt.

My apologies Happygal, I misunderstood how you wanted to tackle the exception path.

In this case, you’re handling it perfectly by invoking the Exception workflow if the else portion of the If activity. The Break activity should also be in the else portion to prevent the For Each activity from processing anymore items in the loop.

If the workflow isn’t behaving the way you would expect, feel free to post the xaml file and I’ll hop in and take a look (just don’t forget to remove any proprietary information if applicable) :slightly_smiling_face:

Use Throw Activity

The Expression inside it would be:

new BusinessRelatedException("Error! A business rule was violated!")

I made a simple xaml file, and when I tired the try-catch and break it works. However, when I place the same logic into my actual workflow, it still continues the loop.

I also tried to put in 2 break activities. When I tried this, it stopped the loop, but the bot was paused on the 2nd break. Is it possible to put a ‘terminate’ activity after the exception workflow has finished? If I did this, would the bot still be able to pick up the next work item in the queue and start the entire process again, or would this ‘terminate’ activity affect the bot from grabbing the next item to work on?

I should also mention that the for-each loop is also inside a while-loop. Does that affect the position of where i put the break? If it does, where should the break be placed?