Guys i want to ask, is it possible to re-run the program from the beginning when any error occur? and if its possible how to do that? Thanks
You could do something like that, of course it’s just the simplest example ever. Take a look at Robotic Enterprise Framework to see more appropriate example.
Inside the Try Catch-> Try block place your logic like this
Inside the Try Catch-> Catch block create catch for System.Exception and place your logic like this. Now your process will be repeated up to the number of times you specify in the rerunMaxCount.
Inside Flow Decision add rerun as a Condition
With this setup your workflow will run up to 3 times if exception happens. Please remember to add important workflows as well, like closing all of the applications in case of exception.
Hi @GT_Ropa thanks for the help, gonna try it later!
Hi @GT_Ropa sorry i want to ask something
U mean my logic is my workflow right?. Im sorry maybe this is stupid question but im new in RPA. Im still exploring this. Thanks
@Kelvin1 Exactly, it’s
you specified in the 1st post. Basically anything your robot does.
@GT_Ropa I dont need put something in “Finally” section ?
No, finally section will execute as last.
What you want to do here, is to put your program in Try section. If any exception happens, then it will be caught into the Catches section by the System.Exception catch.
In general putting code/activities into Finally section is not recommended, the reason being if there is any non caught exception or you rethrow the exception in Catches section, finally block will not be executed
hi @GT_Ropa so i already did the instruction that u gave to me. Can u please explain about the rerun = false and rerun = true. What is that mean?
Sure. In the Flow Decision
You are using the rerun flag(boolean variable TRUE/FALSE) to check weather the robot should be ran again.
If rerun = TRUE, then robot will run again
If rerun = FALSE, then robot will stop afte the execution.
In the screenshot I presented you a simple workflow with 3 variables
rerun (boolean) = false ← boolean will always have it’s default value set to FALSE
count (int) = 0
rerunMaxCount (int) = 3
Whenever the exception happens in your program (inside the Try segment), robot will go to Catches segment.
Robot will check if condition (if count < rerunMaxCount)
When this condition is true, robot will set the rerun variable to True.
rerun = true
This means that exception happened and you want to run your program once more.
However, if your program fails due to some software or data problem, it would try to run infinitely(because every time exception happens the rerun will be set to true).
That’s why we add +1 to count variable every time exception happens.
First time exception happens: count = 0, rerunMaxCount = 3 => count < 3
Second time: count = 1, rerunMaxCount = 3 => count < 3
Third time: count = 2, rerunMaxCount = 3 => count < 3
Fourth time: count = 3, rerunMaxCount = 3 => count = 3
At fouth attempt, the condition in IF statement won’t be satisfied and robot will assign FALSE to rerun variable. This way robot will stop working. It’s just a safe mechanism.
The rerun = False inside of Try segment after your program is set in case that the program fails once and next time it run correctly so you don’t want to rerun it again.
Have you used Re-framework beofre? If not, just have a look into it. In that if there is any system exception happens during processing it will go to initialization stage where the restart of the automation happens.
Here also you can use the same logic, you can use try catch and if the catch happens you need to go back to the first stage of your automation.
Oh my god, thanks for the explanation man, appreciated! @GT_Ropa
Hi @GT_Ropa i wanna ask 1 last question about catch section in try catch. In that section u told me to create catch for system.exception, does that exception will re-run program if anything error happen? or just specific exception only?
The System.Exception is the base class for all the exceptions in .Net (UiPath too). It will catch every exception that happens.
You can also add specific exceptions as well. For example if you know that sometimes the application does not launch properly you can specify
This exception usually happens when application is not opened but you are trying to use it.
In case of any other exceptions, you can simply look it up in output panel (In the lower left corner of the UiPath Studio by default)after it happens:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.