filter network errors globally in sentry
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import {LexError} from '@atproto/lex'
|
||||
import {t} from '@lingui/core/macro'
|
||||
|
||||
import {isNetworkError} from '#/lib/network-error'
|
||||
import {isXrpcError} from '#/lib/xrpc-error'
|
||||
|
||||
export {isNetworkError} from '#/lib/network-error'
|
||||
|
||||
/**
|
||||
* The text to show the user when no special case applies.
|
||||
*
|
||||
@@ -79,26 +82,6 @@ export function cleanError(e: unknown): string {
|
||||
return toDisplayString(e, str)
|
||||
}
|
||||
|
||||
const NETWORK_ERRORS = [
|
||||
'Abort',
|
||||
'Network request failed',
|
||||
'Failed to fetch',
|
||||
'fetch failed',
|
||||
'Load failed',
|
||||
'Upstream service unreachable',
|
||||
'NetworkError when attempting to fetch resource',
|
||||
]
|
||||
|
||||
export function isNetworkError(e: unknown) {
|
||||
const str = String(e)
|
||||
for (const err of NETWORK_ERRORS) {
|
||||
if (str.includes(err)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* The PDS answers an app-password-scope rejection with the lexicon code
|
||||
* `InvalidToken` and a message of 'Bad token scope' or 'Bad token method'
|
||||
|
||||
Reference in New Issue
Block a user