Search code examples
javascriptloggingbrowsererror-handlingsentry

How can I prevent Sentry from reporting an error in javascript in the browswer?


It seems like Sentry is reporting an error I intentionally swallow. Why is this? How can I tell Sentry not to report on this swallowed error?

Sentry Screenshot


Solution

  • Sentry.init({
      ignoreErrors: ['NotSupportedError']
      // or
      ignoreErrors: [/operation is not supported/]
    })
    

    or with beforeSend

    Sentry.init({
      beforeSend(event) {
        // or `value` instead of a `type`
        if (event.exception && event.exception.values[0].type === 'NotSupportedError') {
          return null
        }
        return event;
      }
    })