Skip to content

Commit 59b4e5e

Browse files
committed
fix: adding error handling when unable to connect to marble when loggin + improve error messages
1 parent dcd7a50 commit 59b4e5e

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

packages/app-builder/src/components/Auth/AuthError.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const errorLabels: Record<AuthErrors, ParseKeys<typeof authI18n>> = {
99
NoAccount: 'auth:errors.no_account',
1010
CSRFError: 'auth:errors.csrf_error',
1111
Unknown: 'common:errors.unknown',
12+
BackendUnavailable: 'common:errors.backend_unvailable',
1213
};
1314

1415
export function AuthError({

packages/app-builder/src/locales/ar/common.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"errors.data.duplicate_link_name": "هذا الرابط موجود مسبقًا.",
2323
"errors.add_to_case.invalid": "هذا القرار مرتبط بالحالة مسبقا",
2424
"errors.firebase_auth_error": "حدث خطأ في المصادقة. يرجى محاولة تسجيل الدخول مرة أخرى.",
25-
"errors.firebase_network_error": "حدث خطأ في الشبكة. يرجى محاولة تسجيل الدخول مرة أخرى.",
2625
"cancel": "الغاء",
2726
"save": "حفظ",
2827
"delete": "حذف",
@@ -62,5 +61,7 @@
6261
"check_on_docs": "تعرف على المزيد حول وثائقنا",
6362
"github_banner": "هل أعجبك تطبيق ماربل؟ \nادعم مجهود المصدر المفتوح من خلال إعطائنا نجمة",
6463
"premium": "ميزة متميزة",
65-
"upgrade": "قم بالترقية الآن"
64+
"upgrade": "قم بالترقية الآن",
65+
"errors.backend_unvailable": "لا يمكن لتطبيق Marble التواصل مع الواجهة الخلفية لـ Marble. \nقم إما بالتحقق من التكوين الخاص بك أو حاول مرة أخرى لاحقًا.",
66+
"errors.firebase_network_error": "يواجه الرخام بعض الصعوبات في الاتصال بـ Firebase. \nقم إما بالتحقق من تكوين Firebase أو حاول مرة أخرى لاحقًا."
6667
}

packages/app-builder/src/locales/en/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"validation_error_other": "{{count}} validation errors",
1515
"errors.forbidden.title": "Forbidden",
1616
"errors.forbidden.subtitle": "You don't have permission to access this page",
17+
"errors.backend_unvailable": "The Marble app cannot communicate with the Marble backend. Either check your configuration or try again later.",
1718
"errors.unknown": "An unknown error as occured",
1819
"errors.account_exists_with_different_credential": "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.",
1920
"errors.popup_blocked_by_client": "The popup has been blocked. Please <EnablePopup>enable popups</EnablePopup> and try again.",
@@ -27,7 +28,7 @@
2728
"errors.data.duplicate_link_name": "A link with this name already exist",
2829
"errors.add_to_case.invalid": "A decision already belongs to a case",
2930
"errors.firebase_auth_error": "An auth error occured. Try to log in again.",
30-
"errors.firebase_network_error": "A network error occured. Try to log in again.",
31+
"errors.firebase_network_error": "Marble has some difficulties to connect to Firebase. Either check your Firebase's configuration or try again later.",
3132
"errors.too_many_requests": "Too many requests. Please try again later.",
3233
"cancel": "Cancel",
3334
"check_on_docs": "Learn more on our documentation",

packages/app-builder/src/locales/fr/common.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"errors.data.duplicate_link_name": "Un lien avec ce nom existe déjà",
3030
"errors.data.duplicate_table_name": "Une table portant ce nom existe déjà",
3131
"errors.firebase_auth_error": "Une erreur d'authentification s'est produite. \nEssayez de vous connecter à nouveau.",
32-
"errors.firebase_network_error": "Une erreur réseau s'est produite. \nEssayez de vous connecter à nouveau.",
3332
"errors.forbidden.subtitle": "Vous n'êtes pas autorisé à accéder à cette page",
3433
"errors.forbidden.title": "Accès interdit",
3534
"errors.list.duplicate_email": "Cet email est déjà utilisé",
@@ -62,5 +61,7 @@
6261
"check_on_docs": "En savoir plus sur notre documentation",
6362
"github_banner": "Aimez-vous l'application Marble ? Dites le nous en nous attribuant une étoile sur",
6463
"premium": "Fonctionnalité Premium",
65-
"upgrade": "Mettre à niveau maintenant"
64+
"upgrade": "Mettre à niveau maintenant",
65+
"errors.backend_unvailable": "L'application Marble ne peut pas communiquer avec le backend Marble. \nVérifiez votre configuration ou réessayez ultérieurement.",
66+
"errors.firebase_network_error": "Marble a quelques difficultés à se connecter à Firebase. \nVérifiez la configuration de Firebase ou réessayez ultérieurement."
6667
}

packages/app-builder/src/models/auth-errors.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { CSRFError } from 'remix-utils/csrf/server';
22

33
import { isMarbleError, isUnauthorizedHttpError } from './http-errors';
44

5-
export type AuthErrors = 'NoAccount' | 'CSRFError' | 'Unknown';
5+
export type AuthErrors =
6+
| 'NoAccount'
7+
| 'CSRFError'
8+
| 'BackendUnavailable'
9+
| 'Unknown';
610

711
export function adaptAuthErrors(error: unknown): AuthErrors {
812
if (error instanceof CSRFError) {

packages/app-builder/src/routes/_auth+/sign-in.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
useLoaderData,
1818
useSearchParams,
1919
} from '@remix-run/react';
20+
import { tryit } from 'radash';
2021
import { Trans, useTranslation } from 'react-i18next';
2122
import { safeRedirect } from 'remix-utils/safe-redirect';
2223

@@ -30,10 +31,15 @@ export async function loader({ request }: LoaderFunctionArgs) {
3031
successRedirect: getRoute('/app-router'),
3132
});
3233
const session = await authSessionService.getSession(request);
33-
const error = session.get('authError');
34+
const [backendError, isSsoEnabled] = await tryit(
35+
licenseService.isSsoEnabled,
36+
)();
37+
3438
return json({
35-
authError: error?.message,
36-
isSsoEnabled: await licenseService.isSsoEnabled(),
39+
authError: backendError
40+
? 'BackendUnavailable'
41+
: session.get('authError')?.message,
42+
isSsoEnabled,
3743
});
3844
}
3945

0 commit comments

Comments
 (0)