This action allows you to:
-
Monitor errors while the actions are being executed.
-
Run an alternative set of actions if an error occurs.
Try action creates Do and On error placeholders for actions. All actions that should execute if a trigger fires, must be placed inside the Do placeholder. If no error is detected when executing actions from Do placeholder, these are the only actions that ever execute. However, if an error does happen, the execution of actions from Do placeholder stops and the execution switches over to actions from On error placeholder.
Note | |
---|---|
You must enable Synchronous Printing to catch errors with On error. |
Example 84. Example
If any action in the Do placeholder fails, the action execution stops and resumes with the actions in the On Error placeholder. If Try would be placed on its own, that would terminate the trigger execution. In our case, Try is nested under the For loop action. Normally, any error in Do placeholder would also stop executing the For loop action, even if there are still further steps until the For loop is complete. In this case, the Save Data to File action does not execute as well. By default, each error breaks the entire trigger processing.
However, you can also continue with the execution of the next iteration in the For loop action. To make this happen, enable the Ignore failure option in the Try action. If the data from the current step in For Loop causes an error in the Do placeholder, the actions from On Error execute. After that, the Save Data to File in level 2 execute and then the For loop action continues to execute in the next iteration.
Tip | |
---|---|
This action provides for an easy error detection and execution of "feedback" or "reporting" actions. For example, if an error happens during trigger processing, you can send out a warning. For more information, see section Print Job Status Feedback in Loftware Automation user guide. |
Note | |
---|---|
Important! The Try action gives expected results with asynchronous actions. If your Try loop includes the Print Label action that fails, the action execution still completes the Try loop, and does not switch to the On error actions as expected. The result for not switching to the On error actions is the Print Label action that runs in synchronous mode by default. To avoid this, make sure supervised printing is on. Go to trigger settings > Other > Feedback from the Print Engine and enable Supervised printing. Read more about supervised printing in section Synchronous Print Mode. |