Skip to content

Commit

Permalink
Better error message (+ translations!) (#6349)
Browse files Browse the repository at this point in the history
* clean network errors for new common eerors

* translate errors
  • Loading branch information
mozzius authored Nov 15, 2024
1 parent 3bd1437 commit a9cacbf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/strings/errors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {t} from '@lingui/macro'

export function cleanError(str: any): string {
if (!str) {
return ''
Expand All @@ -6,13 +8,17 @@ export function cleanError(str: any): string {
str = str.toString()
}
if (isNetworkError(str)) {
return 'Unable to connect. Please check your internet connection and try again.'
return t`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('Upstream Failure') ||
str.includes('NotEnoughResources') ||
str.includes('pipethrough network error')
) {
return t`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.'
return t`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)
Expand Down

0 comments on commit a9cacbf

Please sign in to comment.