Ideally not…we need to use tey catch only when necessary like say ypu have some specific activities you need to do when exception occurs and then throw the error then use try catch to do that
Similarly if you have a need to do a different set of steps when exception occurs then use try catch and change flow accordingly
Actually no need to use try catch for every workflow in RE Frameworks. RE Frameworks is already designed to handle the exceptions.
In any of the workflow in the the four states throws the error the RE Frameworks identify the error weather it is Business exception or System exception it will handle itself.
Let us consider there are two workflows, name it as Workflow1 and Workflow2.
The Workflow1 is in the process state, the workflow2 is invoking to workflow1. To throw the exceptions in workflow2 we have to encapsulate the workflow2 with try catch. Then If any exception is occured in Workflow2 the Rethrow activity which is in catch block throws exception to workflow1. Workflow1 is already in process state. Then REFrameworks will automatically handle the exception in Workflow1.
Remind this In RE Frameworks every state can handled the exceptions. It was designed mainly for retry mechanism, Transaction Iteration and Exception handling.
So, one should only throw BE right ? Rather rethrow from inner catch to outer catch …With proper message …Is my understanding correct now ??
2.all SE framework will take care no need to handle them unless required.
Can I use throw BE 2 ,3times in same workflow ? And catch only once ? By giving log msg . +Exception.msg
And rethrow only once ?
… so that that exception msg will come till set transaction status.
Yes don’t need to use try catch until unless required. If you know at anywhere the business exception is required you have to use throw.
You can use the throw activity 2 or 3 times if required in the workflow, based on the exception. If it is System exception it will trigger to system exception sequence in set transaction status and it will go from process state to Initialization state, If it is Business exception it will trigger to business Exception sequence in set transaction status then it will go from process state to Get transaction state.
Try catch is not only for business exception…and throw also is not only for BE
For instance you have a web page and you are navigating to a page…then we can check for page transition and if the new page is kot loaded we can throw a system exception in that case…
Two ways to handle it is…one to check for element and throw using element exists or check apps tate…other way is to use a try catch around the next activity that happens on the target page and throw an exception in the catch block…
Both ways are legit. Where one is proactive and other is reactive…
Similarly…when we want to give any custom messaging instead of the same exception that UiPath throws…for example…object ref nit set to an instance of object is a generic message we get when null variable is present…instead of let it go to the top layer…we can use a try catch where we feel this might occur and catch the nullrefexception anf throw with a different user friendly message …even for that we can use a try catch inside instead of the ones that are available at the top layer