Skip to content

Sentry trpcMiddleware reports bad request and not found from trpc #10748

Answered by gpichot
gpichot asked this question in Q&A
Discussion options

You must be logged in to vote

Ok thanks, I missed this second argument :).

I went with:

const WhiteListedErrorCodes = ["UNAUTHORIZED", "NOT_FOUND", "BAD_REQUEST"];

Sentry.init({ 
    // ...
    beforeSend(event, hint) {
    if (
      hint.originalException instanceof TRPCError &&
      WhiteListedErrorCodes.includes(hint.originalException.code)
    ) {
      return null;
    }

    return event;
  },
})

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@gpichot
Comment options

@AbhiPrasad
Comment options

@gpichot
Comment options

Answer selected by AbhiPrasad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants