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

feat: exceptionHandler #276

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

AndreiAlexandruParaschiv
Copy link
Contributor

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Thanks for contributing!

Copy link

github-actions bot commented Jul 1, 2024

This PR will trigger a minor release when merged.

Copy link
Contributor

@iuliag iuliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To put things in a larger perspective:

@@ -66,11 +66,11 @@ export const createKeyEvent = (data) => {
}

if (!Object.values(KEY_EVENT_TYPES).includes(newState.type.toUpperCase())) {
throw new Error(`Unknown value for "type": ${newState.type}`);
throw new ClientError(`Unknown value for "type": ${newState.type}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClientErrors are not only validation errors, where we return 400. They can be all 400-499 status codes.
If we want a quick fix, I recommend adding proper try-catch return badRequest in the key events controller.
If we want a long-term pattern, we should address main types of client errors with the corresponding status code.

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 this pull request may close these issues.

2 participants