(aws-stepfunctions): Include an ICatchable interface for step function states
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the feature
I find myself repeatedly declaring the following trivial interface:
```typescript
export type ICatchable = {
addCatch(handler: sfn.IChainable, props?: sfn.CatchProps): sfn.INextable
};
```
I think this would be useful to others if included in [`aws-stepfunctions/lib/types.ts`](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions/lib/types.ts) alongside the existing interfaces such as `IChainable` and `INextable`.
### Use Case
When writing reusable code to produce specific idioms in a step function definition, I often want to declare a parameter as taking a piece of logic that I can catch exceptions from.
### Proposed Solution
By annotating the parameter as (for example) `IChainable & ICatchable`, the function indicates clearly that it intends to attach a catch clause to the state(s).
### Other Information
An alternative is for the callee (the reusable idiom) to check for the existence of an `.addCatch()` method, or do other introspection on the passed-in chain, and call `.toSingleState()` if needed. I prefer the interface declaration, as it is "less magic" from the user's perspective, and also serves as documentation of what the idiom is planning to do.
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS CDK Library version (aws-cdk-lib)
v2.217.0
### AWS CDK CLI version
n/a
### Environment details (OS name and version, etc.)
All
Contributor guide
Research direction
Start in aws-stepfunctions/lib/types.ts and read the existing IChainable and INextable interfaces. Add the requested ICatchable interface with the shown addCatch signature, then verify that it is exported alongside the existing interfaces and supports the documented IChainable & ICatchable use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100