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

Closed
mrgrain opened this issue Dec 1, 2024 · 2 comments · Fixed by #32548
Closed

Typed Errors for cli/toolkit #32347

mrgrain opened this issue Dec 1, 2024 · 2 comments · Fixed by #32548
Assignees
Labels

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.

Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants