remove duplicated list of errors
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import {useCallback} from 'react'
|
import {useCallback} from 'react'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
|
import {NETWORK_ERRORS} from '#/lib/strings/errors'
|
||||||
|
|
||||||
type CleanedError = {
|
type CleanedError = {
|
||||||
raw: string | undefined
|
raw: string | undefined
|
||||||
clean: string | undefined
|
clean: string | undefined
|
||||||
@@ -82,14 +84,6 @@ export function useCleanError() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const NETWORK_ERRORS = [
|
|
||||||
'Abort',
|
|
||||||
'Network request failed',
|
|
||||||
'Failed to fetch',
|
|
||||||
'Load failed',
|
|
||||||
'Upstream service unreachable',
|
|
||||||
]
|
|
||||||
|
|
||||||
export function isNetworkError(e: unknown) {
|
export function isNetworkError(e: unknown) {
|
||||||
const str = String(e)
|
const str = String(e)
|
||||||
for (const err of NETWORK_ERRORS) {
|
for (const err of NETWORK_ERRORS) {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export function cleanError(e: unknown): string {
|
|||||||
return toDisplayString(e, str)
|
return toDisplayString(e, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
const NETWORK_ERRORS = [
|
export const NETWORK_ERRORS = [
|
||||||
'Abort',
|
'Abort',
|
||||||
'Network request failed',
|
'Network request failed',
|
||||||
'Network request timed out',
|
'Network request timed out',
|
||||||
|
|||||||
Reference in New Issue
Block a user