Files
bsky-social-app/src/lib/strings/errors.ts
T
Samuel Newman b093e0b673 [🐴] better error message for "Bad token scope" error (#4194)
* better error message for "Bad token scope" error

* log -> sign
2024-05-23 18:05:30 +01:00

31 lines
847 B
TypeScript

export function cleanError(str: any): string {
if (!str) {
return ''
}
if (typeof str !== 'string') {
str = str.toString()
}
if (isNetworkError(str)) {
return 'Unable to connect. Please check your internet connection and try again.'
}
if (str.includes('Upstream Failure')) {
return 'The server appears to be experiencing issues. Please try again in a few moments.'
}
if (str.includes('Bad token scope')) {
return 'This feature is not available while using an App Password. Please sign in with your main password.'
}
if (str.startsWith('Error: ')) {
return str.slice('Error: '.length)
}
return str
}
export function isNetworkError(e: unknown) {
const str = String(e)
return (
str.includes('Abort') ||
str.includes('Network request failed') ||
str.includes('Failed to fetch')
)
}