filter network errors globally in sentry

This commit is contained in:
Samuel Newman
2026-08-28 14:59:16 +01:00
parent 076cdd650d
commit 1d136b07ed
8 changed files with 271 additions and 30 deletions
+3 -20
View File
@@ -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'