Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥅 show THI backend error #336

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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