Hello @Kelvin1
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.
Thanks