mirror of
https://github.com/twentyhq/twenty.git
synced 2025-01-06 03:45:15 +03:00
Fix exception handler capturing graphql errors (#5714)
Our exception handler has to filter out some errors/exceptions so they are not caught by the ExceptionHandlerDriver (Logged or Sentry for example). This is done for Http errors in the range of 4xx and also makes sure they are converted back to Graphql validation errors. However, graphql validation errors that are already managed by Yoga (with Schema validation) should also be filtered out, this PR should fix that behaviour
This commit is contained in:
parent
2d12984db4
commit
e2dc660d18
@ -1,5 +1,7 @@
|
||||
import { HttpException } from '@nestjs/common';
|
||||
|
||||
import { GraphQLError } from 'graphql';
|
||||
|
||||
import { ExceptionHandlerUser } from 'src/engine/integrations/exception-handler/interfaces/exception-handler-user.interface';
|
||||
|
||||
import {
|
||||
@ -35,6 +37,12 @@ export const handleExceptionAndConvertToGraphQLError = (
|
||||
};
|
||||
|
||||
export const shouldFilterException = (exception: Error): boolean => {
|
||||
if (
|
||||
exception instanceof GraphQLError &&
|
||||
(exception?.extensions?.http?.status ?? 500) < 500
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (exception instanceof HttpException && exception.getStatus() < 500) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user