Deploy exception handling
When a flow runs, a user might encounter unforeseen circumstances, resulting in it stopping due to an error. To avoid errors, users can configure exception handling rules, so that the flow can recover and continue running.
In the flow designer, exception handling can be applied to individual actions.
Exception handling
Exceptions can occur from virtually any action. For this reason, most actions’ properties contain an On error button.
In our example, the flow is executed in company devices where the Excel file can be in either the C: or the D: drive. The rest of the path location is the same. For this situation we could configure the Launch Excel action so that, if it fails to open the file from the C:, it attempts to open it from the D: path.
To achieve this, we double-click on the action to edit it and select the On error button in the bottom left of the popup:
You can adjust the Retry policy option. By default, it is "None," but you can define either a "Fixed" or an "Exponential" policy. If you want it to define a fixed number of retries, you can then specify the number of times and the interval (in seconds). Selecting the Fixed retry will retry the action one more time after an interval of 2 seconds, by default. You can adjust these settings later on.
Then select the Continue flow run option.
You have a few options to handle the exception. You can either go to the next action, repeat the existing one, or go to a label.
The selected options take effect when this action encounters an exception. To open a file in a different path, we have to create a new subflow that does exactly that. The Advanced section allows you to create rules, which allow you to run Subflows.
Then configure the previous action’s exception handling accordingly, by pressing New rule and selecting Run subflow:
In our example, if the Excel file can't be opened in its usual path, the Alternative Path subflow runs, opening the file in its alternative path, then the flow resumes running.