Commit ee563829 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

fix: ignores "user rejected transaction" errors (#6330)

* ignore user rejected errors

* test

* fix

* use util
parent 64e396d9
...@@ -19,4 +19,9 @@ describe('filterKnownErrors', () => { ...@@ -19,4 +19,9 @@ describe('filterKnownErrors', () => {
const originalException = new Error('underlying network changed') const originalException = new Error('underlying network changed')
expect(filterKnownErrors(ERROR, { originalException })).toBe(null) expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
}) })
it('filters user rejected request errors', () => {
const originalException = new Error('user rejected transaction')
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
})
}) })
import { ClientOptions, ErrorEvent, EventHint } from '@sentry/types' import { ClientOptions, ErrorEvent, EventHint } from '@sentry/types'
import { didUserReject } from 'utils/swapErrorToUserReadableMessage'
/** Identifies ethers request errors (as thrown by {@type import(@ethersproject/web).fetchJson}). */ /** Identifies ethers request errors (as thrown by {@type import(@ethersproject/web).fetchJson}). */
function isEthersRequestError(error: Error): error is Error & { requestBody: string } { function isEthersRequestError(error: Error): error is Error & { requestBody: string } {
...@@ -21,6 +22,9 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event: ...@@ -21,6 +22,9 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
// If the error is a network change, it should not be considered an exception. // If the error is a network change, it should not be considered an exception.
if (error.message.match(/underlying network changed/)) return null if (error.message.match(/underlying network changed/)) return null
// If the error is based on a user rejecting, it should not be considered an exception.
if (didUserReject(error)) return null
} }
return event return event
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment