Skip to content
Miriam McMahon edited this page Apr 27, 2023 · 5 revisions

Description

A try block is used to encapsulate commands and perform error handling. If any command throws an error within the try block, it will be handled by the corresponding catch block. The finally block contains a set of commands to execute at the end, regardless of whether 1 or more errors occurred. Try blocks can be nested. An error thrown in a nested Catch block will be caught by the Catch block of the containing Try.

Parameters

Parameter Name Description Type Resolved Type Required
Do The Do block encapsulates the set of commands to run the Try block. Do Block Do Block Yes
Catch Contains the commands that will be executed if anything in the Do block throws. The string variable 'Exception' contains the error that was caught. Do Block Do Block No
Finally The set of commands that will be executed regardless of the whether 1 or more errors occurred. Do Block Do Block No

Examples

Example:

{
  "Try": {
    "Do": [
      {
        "Function": {
          "Name": "TestThrow",
          "ResultVariable": "TestThrowResult"
        }
      }
    ],
    "Catch": [
      {
        "Comment": { "Text": "TestThrow threw an error!" }
      },
      {
	"Log" : { "Text":  "The error that was thrown is: %Exception%" }
      }
    ],
    "Finally": [
      {
        "Return": { "Value": false }
      }
    ]
  }
}