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 f801e9be71ae..946b90ec28ba 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; };