Skip to content

Typed Errors for cli/toolkit #32347

@mrgrain

Description

@mrgrain
  • Introduce a new typed error into the CLI: ToolkitError, see errors.ts from aws-cdk-lib for an example however ToolkitError will not take a scope as input.
  • Implement a static isToolkitError message on the ToolkitError class
  • Implement an AuthenticationError that extends ToolkitError and sets type 'authentication'
  • Every error we throw in the CLI should throw ToolkitError or AuthenticationError depending on the situation.
  • Enforce this usage by configuring the no-throw-default-error rule from cdklabs/eslint-rules for the aws-cdk package (do this first)
    • Top tip: extend the linter fix suggestions here to add a new suggestion for ToolkitError/AuthenticationError. If you do that and enable the linter rule, changing every error will be almost automatic and super easy. I highly recommend you do this.

Errors that are re-thrown unchanged, should stay like that. Existing typed errors (like CfnEvaluationException) should be converted into our new error system.

Create all new files inside a new directory lib/toolkit. All files and classes should be private.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions