Skip to content

Commit

Permalink
🥅 show THI backend error
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildmodeOne committed Oct 6, 2023
1 parent 89a4cf0 commit 0a26563
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion rogue-thi-app/pages/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const PRIVACY_URL = process.env.NEXT_PUBLIC_PRIVACY_URL
const GIT_URL = process.env.NEXT_PUBLIC_GIT_URL
const GUEST_ONLY = !!process.env.NEXT_PUBLIC_GUEST_ONLY

const KNOWN_BACKEND_ERRORS = [
'Response is not valid JSON'
]

export default function Login () {
const router = useRouter()
const { redirect } = router.query
Expand Down Expand Up @@ -56,7 +60,12 @@ export default function Login () {
if (e.message.includes(ORIGINAL_ERROR_WRONG_CREDENTIALS)) {
setFailure(t('error.wrongCredentials'))
} else {
setFailure(t('error.generic'))
console.error(e)
if (KNOWN_BACKEND_ERRORS.some(error => e.message.includes(error))) {
setFailure(t('error.backend'))
} else {
setFailure(t('error.generic'))
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion rogue-thi-app/public/locales/de/login.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"error": {
"wrongCredentials": "Deine Zugangsdaten sind falsch.",
"generic": "Bei der Verbindung zum Server ist ein Fehler aufgetreten."
"generic": "Bei der Verbindung zum Server ist ein Fehler aufgetreten.",
"backend": "Das THI Backend ist derzeit nicht erreichbar. Bitte versuche es später erneut."
},
"alert": "Für diese Funktion musst du eingeloggt sein.",
"guestOnly": {
Expand Down
3 changes: 2 additions & 1 deletion rogue-thi-app/public/locales/en/login.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"error": {
"wrongCredentials": "Your login credentials are incorrect.",
"generic": "An error occurred while connecting to the server."
"generic": "An error occurred while connecting to the server.",
"backend": "The THI backend is currently unavailable. Please try again later."
},
"alert": "You must be logged in to use this feature.",
"guestOnly": {
Expand Down

0 comments on commit 0a26563

Please sign in to comment.