From 87fe33209492e2fb850c8ee3def81e86f9ba0113 Mon Sep 17 00:00:00 2001 From: Thomas Trompette Date: Mon, 29 Jul 2024 14:35:58 +0200 Subject: [PATCH] Filter out by error code --- .../utils/should-capture-exception.util.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/graphql/utils/should-capture-exception.util.ts b/packages/twenty-server/src/engine/core-modules/graphql/utils/should-capture-exception.util.ts index f801e9be71ae1..946b90ec28ba8 100644 --- a/packages/twenty-server/src/engine/core-modules/graphql/utils/should-capture-exception.util.ts +++ b/packages/twenty-server/src/engine/core-modules/graphql/utils/should-capture-exception.util.ts @@ -1,9 +1,6 @@ -import { - BaseGraphQLError, - ErrorCode, -} from 'src/engine/core-modules/graphql/utils/graphql-errors.util'; +import { ErrorCode } from 'src/engine/core-modules/graphql/utils/graphql-errors.util'; -export const graphQLErrorCodesToFilter = [ +export const graphQLErrorCodesToFilterOut = [ ErrorCode.GRAPHQL_VALIDATION_FAILED, ErrorCode.UNAUTHENTICATED, ErrorCode.FORBIDDEN, @@ -15,12 +12,15 @@ export const graphQLErrorCodesToFilter = [ ]; export const shouldCaptureException = (exception: Error): boolean => { + // @ts-expect-error - extensions is not defined on Error + const graphQLErrorCode = exception?.extensions?.code; + if ( - exception instanceof BaseGraphQLError && - graphQLErrorCodesToFilter.includes(exception?.extensions?.code) + graphQLErrorCode && + graphQLErrorCodesToFilterOut.includes(graphQLErrorCode) ) { - return true; + return false; } - return false; + return true; };