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

Fix metadata exception handler #2 #3357

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Jan 10, 2024

Context

Follow up #3335

The first fix was not working for metadata due to the ExceptionHandlerService not being injected in the module factory. This PR should fix this.
I also fixed a typo in the ExceptionHandlerSentryDriverFactoryOptions interface and changed a bit the logic of the global exception handler to capture all exceptions except httpExceptions with statusCode < 500. This means now not only HttpException >= 500 and typeORM exceptions but anything extending Error or Error itself should be captured.
Due to that change, I've checked metadata module to replace the different "throw new Error" accordingly.

With our implementation of nestjs-query, all the logic lives inside a service instead of a resolver (which is automatically generated for us), including the validation logic. Ideally we should not throw http-related exceptions to

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

Great!

(exception instanceof HttpException && exception.getStatus() >= 500)
) {
exceptionHandlerService.captureException(exception);
if (exception instanceof HttpException && exception.getStatus() < 500) {
Copy link
Member

Choose a reason for hiding this comment

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

+1

}

return maskError(error, message, isDev);
Copy link
Member

Choose a reason for hiding this comment

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

+1

@charlesBochet charlesBochet merged commit 22047fa into main Jan 10, 2024
8 of 12 checks passed
@charlesBochet charlesBochet deleted the c--fix-metadata-exception-handler branch January 10, 2024 16:02
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.

None yet

2 participants