Try

The Try Action is used to perform a Try-Catch statement. It consists of two branches: the Try expression and the Catch expression, each of which consist of their own separate Action Chains:

Additional Actions can be added to both the Try expression and the Catch expression by clicking on the '+' icon that appears to the right of the relevant branch.

The Try expression is evaluated first. If it can be evaluated without throwing an error, then the Action Chain given by the Try expression will fire as normal, and the Action Chain given by the Catch expression will not be. However, if the Action Chain defined by the Try expression does throw an error, then the Action Chain defined by the Catch expression will be fired instead.

Use Cases

The Try Action can be used whenever errors are periodically expected – in evaluating either a full Action or an Airscript expression given to it – and can be handled gracefully. The details of how this is applied tend to vary importantly based on the flow of an individual application, so let's consider a representative example.

Say we have an application that looks up user information in an external API. This information includes the user's phone number, which is then used to send the user an SMS Notification.

However, external APIs might have their own limitations, and there's a small chance this external API might not always be able to provide the user's phone number correctly. In such cases, the application might throw an error rather than send an outgoing SMS Notification, and this is where the Try Action can be useful. The Try Action can be used to attempt to send the SMS Notification based on the phone number pulled from the external API: if no error is thrown in the process, the SMS Notification will be sent, but if an error is thrown, another Action Chain can be fired instead – perhaps one that directs the user to a new Web Page that asks them to provide their phone number directly.

Properties

Try expression

The Action Chain to try. Typically, this Action Chain is expected to periodically throw an error, at which point evaluation of the Try expression will end and the Catch expression will be fired instead.

Catch expression

The Action Chain to fire if an Action in the Try expression throws an error.

Example

This example contains a single Send Email Action under the Try expression and a single Navigate to Web Page Action under the Catch expression.

The Try expression will attempt to send an Email Notification, but Email Notifications can only be sent if the Actor is properly configured; otherwise, it will throw an error. Should this error be thrown, the Catch expression will direct the app user to another Web Page, where they will be prompted to configure their email address before proceeding.