Try-Catch-Finally

This action is used to add Try, Catch, and Finally blocks in order to gracefully handle errors and avoid program crashes.

Here's an example of a Try-Catch action chain that follows this logic: attempt to get the user's location, catch any errors if the location can't be retrieved, and finally run a navigation event (this last event runs whether the request succeeds or fails).

define([
  'vb/action/actionChain',
  'vb/action/actions',
  'vb/action/actionUtils',
], (
  ActionChain,
  Actions,
  ActionUtils
) => {
  'use strict';

  class test extends ActionChain {

    /**
     * @param {Object} context
     */
    async run(context) {
      const { $flow, $application, $constants, $variables } = context;

      try {
        const location = await Actions.geolocation(context, {});

        await Actions.fireNotificationEvent(context, {
          summary: 'City',
        });
      } catch (error) {
        await Actions.fireNotificationEvent(context, {
          summary: 'Error',
        });
      } finally {
        await Actions.fireEvent(context, {
          event: 'application:navigateToItem',
        });
      }
    }
  }

  return test;
});