Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed Errors for cli/toolkit #32347

Open
mrgrain opened this issue Dec 1, 2024 · 0 comments · May be fixed by #32548
Open

Typed Errors for cli/toolkit #32347

mrgrain opened this issue Dec 1, 2024 · 0 comments · May be fixed by #32548
Assignees

Comments

@mrgrain
Copy link
Contributor

mrgrain commented Dec 1, 2024

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants