diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/errors.ts | 4 | ||||
-rw-r--r-- | src/lib/strings.ts | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/errors.ts b/src/lib/errors.ts new file mode 100644 index 000000000..c14a2dbe4 --- /dev/null +++ b/src/lib/errors.ts @@ -0,0 +1,4 @@ +export function isNetworkError(e: unknown) { + const str = String(e) + return str.includes('Aborted') || str.includes('Network request failed') +} diff --git a/src/lib/strings.ts b/src/lib/strings.ts index 66dd59708..0474c330d 100644 --- a/src/lib/strings.ts +++ b/src/lib/strings.ts @@ -1,6 +1,7 @@ import {AtUri} from '../third-party/uri' import {Entity} from '../third-party/api/src/client/types/app/bsky/feed/post' import {PROD_SERVICE} from '../state' +import {isNetworkError} from './errors' import TLDs from 'tlds' export const MAX_DISPLAY_NAME = 64 @@ -201,7 +202,7 @@ export function enforceLen(str: string, len: number): string { } export function cleanError(str: string): string { - if (str.includes('Network request failed')) { + if (isNetworkError(str)) { return 'Unable to connect. Please check your internet connection and try again.' } if (str.startsWith('Error: ')) { |