Reframework - Try-Catch Exception

Hi Friends,
I am working on ReFramework and just a query regarding TryCatch/Exception Handling.
Can we use try catch in other workflows or what is the best best practise in Exception Handling in Reframework.

Thanks
Gaurav Bhargava

@gaurav_rpa
Hi gaurav,
Try catch can be used in any workflows, its functionality is similar to the one provided by general programming languages.
This is the best way to handle exception and ensure that your bot doesn’t run into any trouble.

Thanks @shivagowdavarad,
I used try catch in some workflows but the problem is that when any issue come then bot just shows error but dont stop by itself.
For example if i execute bot and if there is issue coming then bot hang on with error until i click on stop button.

Hi

The main functionality of adding the workflow into TRY CATCH ACTIVITY is to let the bot continue with its execution even though if any exception occurs
That too in REFramework we got some special exception handling like if any system error or application error and business exception occurs they will be handled and made to reiterate and continue with the remaining transaction item
So for this case

Ensure that workflow or sequence of activities where we feel like might come across with errors then bound them with TRY CATCH Block
And in exception catch block mention as System.Exception
So that any kind of exception will be caught with it

Cheers @gaurav_rpa

Thanks @Palaniyappan for the answer.
So my another question is suppose bot is executing on some process and suddenly it faces issue so i want that Bot should be stopped immediately without any click on stop button.

Thanks
Gaurav

1 Like

hi @gaurav_rpa
then you can use a try catch, inside the try put your workflow, in the exception, select System.Exception to handle any possibility exception, and inside that you can use two activities, first one is “Terminate Workflow” and the other one is “Kill Process”.
another option is using the REFramework template, handling separate workflows to close all applications you was open, this should be inside the closeApplications workflow, using any transmit error to this State, if any process fail the bot don’t try to re initiate and go to the “end Process State” where all the processes will be killed and the bot stop.
Regards!

Thanks @fernando_zuluaga,
Actually i am covering code which can throw exception so putting that code in try catch.
So if any error occur i want bot stop on same workflow where error occured and will retry on it for 1-2 times in some particular duration on the basis of error i am trying to implement retry concept.
I am not using orchestrator.

Thanks

Fine then we can use TERMINATE WORKFLOW ACTIVITY in the catch block of the workflow that you want so that if any exception occurs it will be caught by the catch block and terminate workflow file activity will terminate the workflow at that point itself

But I would suggest to go till END STATE as if the workflow is stopped abruptly the applications involved will still be opened and left as it is
So if the same process is ran again the already opened application might affect

As end state has close application xaml it will clear all of those

May be we can set the TRANSITION in such a way like if it fails it must get directed to end state where we can have close application xaml followed terminate workflow file activity
It’s just the way we approach buddy based on the process and it differs

Cheers @gaurav_rpa