# FailProps

Properties for defining a Fail state.

Extends: [StateBaseProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.StateBaseProps.html)
Used as props by: [Fail](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Fail.html)

- Source: [`aws-stepfunctions/lib/states/fail.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-stepfunctions/lib/states/fail.ts#L58)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

TypeScript:

```ts
const fail = new sfn.Fail(this, 'Fail', {
  errorPath: sfn.JsonPath.format('error: {}.', sfn.JsonPath.stringAt('$.someError')),
  causePath: "States.Format('cause: {}.', $.someCause)",
});
```

Python:

```python
fail = sfn.Fail(self, "Fail",
    error_path=sfn.JsonPath.format("error: {}.", sfn.JsonPath.string_at("$.someError")),
    cause_path="States.Format('cause: {}.', $.someCause)"
)
```

Java:

```java
Fail fail = Fail.Builder.create(this, "Fail")
        .errorPath(JsonPath.format("error: {}.", JsonPath.stringAt("$.someError")))
        .causePath("States.Format('cause: {}.', $.someCause)")
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var fail = new Fail(this, "Fail", new FailProps {
    ErrorPath = JsonPath.Format("error: {}.", JsonPath.StringAt("$.someError")),
    CausePath = "States.Format('cause: {}.', $.someCause)"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
fail := sfn.NewFail(this, jsii.String("Fail"), &FailProps{
	ErrorPath: sfn.JsonPath_Format(jsii.String("error: {}."), sfn.JsonPath_StringAt(jsii.String("$.someError"))),
	CausePath: jsii.String("States.Format('cause: {}.', $.someCause)"),
})
```

## Properties

- `cause`: string — A description for the cause of the failure.

  **Default:** No description

- `causePath`: string — JsonPath expression to select part of the state to be the cause to this state.

  **Default:** No cause path

  You can also use an intrinsic function that returns a string to specify this property.
  The allowed functions include States.Format, States.JsonToString, States.ArrayGetItem, States.Base64Encode, States.Base64Decode, States.Hash, and States.UUID.

- `comment`: string — A comment describing this state.

  **Default:** No comment

- `error`: string — Error code used to represent this failure.

  **Default:** No error code

- `errorPath`: string — JsonPath expression to select part of the state to be the error to this state.

  **Default:** No error path

  You can also use an intrinsic function that returns a string to specify this property.
  The allowed functions include States.Format, States.JsonToString, States.ArrayGetItem, States.Base64Encode, States.Base64Decode, States.Hash, and States.UUID.

- `queryLanguage`: [QueryLanguage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.QueryLanguage.html) = JSONPath — The name of the query language used by the state.

  If the state does not contain a `queryLanguage` field,
  then it will use the query language specified in the top-level `queryLanguage` field.

- `stateName`: string — Optional name for this state.

  **Default:** The construct ID will be used as state name
