Add a Try-Catch Action

You add a Try-Catch action to gracefully handle errors and avoid program crashes.

To use a Try-Catch action:
  1. Add the action in one of three ways, as explained at the end of Built-In Actions.
  2. To change the alias for the error object, which has the name and message properties, select the Catch block on the canvas and change the alias in the Properties pane:

  3. To add an action to a Try-Catch block, select the block and double-click the action in the Actions palette, or drag an action from the Action's palette onto the desired block:

When you add a Try-Catch action to an action chain, you can't delete the Catch or Finally block in Design view. However, you can delete these blocks in Code view (by deleting the code that forms these nodes). If you've deleted the Catch or Finally blocks and want to add them back, here's what you can do:
  1. To add a Catch node, in Design view, right-click the try or finally block and click Add Catch.
  2. To add a Finally node, in Design view, right-click the catch block and click Add Finally.


    Description of jsac_try_add_finally.png follows
    Description of the illustration jsac_try_add_finally.png

You can also surround an action with a Try-Catch action by right-clicking it and selecting Surround with Try-Catch:
Description of jsac-surround-try-catch.png follows
Description of the illustration jsac-surround-try-catch.png

If you need a Finally block, you have a few option:
  • To add a Finally block with a specific action, drag the action that you want to the Try-Catch action and drop it into the Create Finally area that appears:

  • To add an empty Finally block, right-click the try or catch block and click Add Finally.