Skip to content
23K
Console

Fail

The Fail state is internally used by the StepFunctions component to add a Fail workflow state to a state machine.

You’ll find this component returned by the fail method of the StepFunctions component.


Constructor

new Fail(args)

Parameters

FailArgs

assign?

Type Record<string, any>

Store variables that can be accessed by any state later in the workflow, instead of passing it through each state.

This takes a set of key/value pairs. Where the key is the name of the variable that can be accessed by any subsequent state.

The value can be any JSON value; object, array, string, number, boolean, null.

{
assign: {
productName: "product1",
count: 42,
available: true
}
}

Or, you can pass in a JSONata expression.

{
assign: {
product: "{% $states.input.order.product %}",
currentPrice: "{% $states.result.Payload.current_price %}"
}
}

Learn more about passing data between states with variables.

cause?

Type Input<string>

A custom string that describes the cause of the error.

{
cause: "User not found"
}

Alternatively, you can specify a JSONata expression that evaluates to a string.

{
cause: "{% $states.input.user %}"
}

error?

Type Input<string>

An error name that you can provide to perform error handling using retry or catch.

{
error: "UserNotFound"
}

Alternatively, you can specify a JSONata expression that evaluates to a string.

{
error: "{% $states.input.error %}"
}

name

Type string

The name of the state. This needs to be unique within the state machine.

output?

Type Input<Record<string, any> | {% ${string} %}>

Transform the output of the state. When specified, the value overrides the default output from the state.

This takes any JSON value; object, array, string, number, boolean, null.

{
output: {
charged: true
}
}

Or, you can pass in a JSONata expression.

{
output: {
product: "{% $states.input.product %}"
}
}

Learn more about transforming data with JSONata.