Skip to content

Commit

Permalink
fix(stepfunctions): make Fail.error optional (#2042)
Browse files Browse the repository at this point in the history
Error codes are optional in ASL.
  • Loading branch information
spg authored and rix0rrr committed Mar 21, 2019
1 parent b93350f commit 86e9d03
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/@aws-cdk/aws-stepfunctions/lib/states/fail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export interface FailProps {

/**
* Error code used to represent this failure
*
* @default No error code
*/
error: string;
error?: string;

/**
* A description for the cause of the failure
Expand All @@ -34,10 +36,10 @@ export interface FailProps {
export class Fail extends State {
public readonly endStates: INextable[] = [];

private readonly error: string;
private readonly error?: string;
private readonly cause?: string;

constructor(scope: cdk.Construct, id: string, props: FailProps) {
constructor(scope: cdk.Construct, id: string, props: FailProps = {}) {
super(scope, id, props);

this.error = props.error;
Expand All @@ -55,4 +57,4 @@ export class Fail extends State {
Cause: this.cause,
};
}
}
}
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-stepfunctions/test/test.fail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import cdk = require('@aws-cdk/cdk');
import { Test } from 'nodeunit';
import stepfunctions = require('../lib');

export = {
'Props are optional'(test: Test) {
const stack = new cdk.Stack();

new stepfunctions.Fail(stack, 'Fail');

test.done();
}
};

0 comments on commit 86e9d03

Please sign in to comment.