Skip to content

Commit

Permalink
Filter out by error code
Browse files Browse the repository at this point in the history
  • Loading branch information
thomtrp committed Jul 29, 2024
1 parent 936279f commit 87fe332
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
};

0 comments on commit 87fe332

Please sign in to comment.