Skip to main content
Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones.

Properties

try
map[string, task]
required
The task(s) to perform.
catch
catch
required
Configures the errors to catch and how to handle them.

Catch Configuration

Defines the configuration of a catch clause, which is a concept used to catch errors.
errors
errorFilter
The definition of the errors to catch.
as
string
default:"error"
The name of the runtime expression variable to save the error as.
when
string
A runtime expression used to determine whether or not to catch the filtered error.
exceptWhen
string
A runtime expression used to determine whether or not to catch the filtered error.
retry
string | retryPolicy
The retry policy to use, if any, when catching errors. If a string, must be the name of a retry policy defined in the workflow’s reusable components.
do
map[string, task]
The definition of the task(s) to run when catching an error.

Example

document:
  dsl: '1.0.3'
  namespace: test
  name: try-example
  version: '0.1.0'
do:
  - trySomething:
      try:
        - invalidHttpCall:
            call: http
            with:
              method: get
              endpoint: https://
      catch:
        errors:
          with:
            type: https://serverlessworkflow.io.io/dsl/errors/types/communication
            status: 503
        as: error
        retry:
          delay:
            seconds: 3
          backoff:
            exponential: {}
          limit:
            attempt:
              count: 5

Build docs developers (and LLMs) love