From 0a265639e062c7c506d1523b80eb0decf36da48c Mon Sep 17 00:00:00 2001 From: Philipp Opheys Date: Fri, 6 Oct 2023 18:54:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20show=20THI=20backend=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rogue-thi-app/pages/login.jsx | 11 ++++++++++- rogue-thi-app/public/locales/de/login.json | 3 ++- rogue-thi-app/public/locales/en/login.json | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/rogue-thi-app/pages/login.jsx b/rogue-thi-app/pages/login.jsx index bea569df..a7b1e0ba 100644 --- a/rogue-thi-app/pages/login.jsx +++ b/rogue-thi-app/pages/login.jsx @@ -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 @@ -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')) + } } } } diff --git a/rogue-thi-app/public/locales/de/login.json b/rogue-thi-app/public/locales/de/login.json index 3b9165fb..a4217351 100644 --- a/rogue-thi-app/public/locales/de/login.json +++ b/rogue-thi-app/public/locales/de/login.json @@ -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": { diff --git a/rogue-thi-app/public/locales/en/login.json b/rogue-thi-app/public/locales/en/login.json index ec63d109..87400a28 100644 --- a/rogue-thi-app/public/locales/en/login.json +++ b/rogue-thi-app/public/locales/en/login.json @@ -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": {