# Reason

Common job exit reasons.

- Source: [`aws-batch/lib/job-definition-base.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-batch/lib/job-definition-base.ts#L215)
- Type last changed: v2.96.0 · 13 Sep 2023

## Example

```ts
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
   container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
  }),
  retryAttempts: 5,
  retryStrategies: [
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER),
  ],
});
jobDefn.addRetryStrategy(
  batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.SPOT_INSTANCE_RECLAIMED),
);
jobDefn.addRetryStrategy(
  batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER),
);
jobDefn.addRetryStrategy(
  batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.custom({
    onExitCode: '40*',
    onReason: 'some reason',
  })),
);
```

## Initializer

```ts
new Reason()
```

## Properties

- `CANNOT_PULL_CONTAINER`: [Reason](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Reason.html) (static) — Will only match if the Docker container could not be pulled.

- `NON_ZERO_EXIT_CODE`: [Reason](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Reason.html) (static) — Will match any non-zero exit code.

- `SPOT_INSTANCE_RECLAIMED`: [Reason](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Reason.html) (static) — Will only match if the Spot instance executing the job was reclaimed.

## Methods

- `custom(customReasonProps: CustomReason): Reason // chainable` (static) — A custom Reason that can match on multiple conditions.

  Note that all specified conditions must be met for this reason to match.
