Adding a Step Outcome for Exceptions

Last Updated: 12/03/2015 Introduced in Verision: 2.0

Even under the best conditions, inputs can be unreliable. To handle missing or invalid data without crashing, steps need paths to account for errors or exceptions. We can add these outcome paths by selecting the Add Outcome for Exception checkbox in the Properties panel and mapping them to steps which can display or otherwise manage errors.

Example

In the example, we will attempt to add an account that already exists in the system using the Add New Account component. When the flow cannot perform this invalid action, rather than stopping, the flow directs to the On Exception path and proceeds to the End Step.

flowRunsWithException

 

Begin in the Flow Designer’s startup window by placing an Add New Account component in the workspace. It can be found in the under the category Integrations > All Integrations > Internal Services > AccountService. Click Add to place component into the workspace.

flowStarts

With the Add New Account step selected, select the Add Outcome for Exception checkbox in the Outcomes section of the Properties panel. This will create a new outcome path on our Add New Account step, called On Exception. Now, whenever the Add New Account step results in an error (say, for example, due to missing inputs), our application’s flow will be directed down the On Exception path, rather than Done.
dragAddAccount
 

Rather than create additional steps to handle our exception, connect the paths On Exception and Done to the end step, and prevent an exception from occurring in another way.

Exception paths are a necessary part of any flow, but we don’t want our flow to follow them except in extreme cases. However, we do want to test our exception path, so we will temporarily remap our inputs to an invalid state. In our application’s database, the user account associated with “user@gmail.com” already exists. We will remap our inputs so that the next time Add New Account runs, it will try to add a user with the same email address, which is an invalid condition.

With the Add New Account 1 selected, from the Properties panel, click the Show Mapping Editor link.
 
When we view Add New Account 1 in the Mapping Editor, we see that all three inputs are currently empty. To modify the account object, we will change its mapping type from Ignore to Constant. Once we’ve done this, the account input will expand to include an option for editing its value. Because the input account is an object, this option appears as a rounded button labeled with an ellipses, indicating that it uses an object editor.

 accountConstant

 

 

Clicking this button reveals all of the properties for the account object input. Right away, we can see two fields that are required, but empty EmailAddress and EntityName. We’ll fill in EmailAddress with our invalid value

 

defineEmail 

. . .and EntityName with “QA.”

entityNameQA

 

Finally we save our changes and click OK to exit the Mapping Editor.

closeMappingEditor

 

Now, when we run our flow in the debugger, we can see that the Add New Account step results in an error, causing our flow to follow the On Exception outcome path. If we want, we can place a variety of display or notification steps to handle this error.

flowRunsWithException

 

Additional Resources