From 1a699b61bc01cb5d26f15d715765cb0f39732a6d Mon Sep 17 00:00:00 2001 From: Monobikash Das Date: Tue, 14 Feb 2023 14:46:20 +0530 Subject: [PATCH] #556 : fixed error messages --- locales/en.json | 3 +++ locales/fil.json | 5 ++++- locales/hin.json | 3 +++ locales/kan.json | 3 +++ locales/tam.json | 3 +++ machines/QrLoginMachine.ts | 5 ++++- machines/vcItem.ts | 6 +++++- screens/Home/MyVcs/AddVcModalMachine.ts | 4 +++- shared/request.ts | 19 ++++++++++++++++++- 9 files changed, 46 insertions(+), 5 deletions(-) diff --git a/locales/en.json b/locales/en.json index 5d074e37..877e443c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -360,6 +360,9 @@ "missingPermission": "This app uses the camera to scan the QR code of another device." }, "allowAccess": "Allow access to the camera" + }, + "errors": { + "genericError": "Something went wrong. Please try again after some time!" } } } diff --git a/locales/fil.json b/locales/fil.json index ff0209d9..e70f10c0 100644 --- a/locales/fil.json +++ b/locales/fil.json @@ -331,6 +331,9 @@ "cancel": "Kanselahin", "save": "I-save", "editLabel": "Palitan ang {{label}}", - "tryAgain": "Subukan muli" + "tryAgain": "Subukan muli", + "errors": { + "genericError": "Nagkaproblema. Pakisubukang muli pagkatapos ng ilang oras!" + } } } \ No newline at end of file diff --git a/locales/hin.json b/locales/hin.json index d4b35b5d..ced80fb8 100644 --- a/locales/hin.json +++ b/locales/hin.json @@ -366,6 +366,9 @@ "missingPermission": "यह ऐप दूसरे डिवाइस के क्यूआर कोड को स्कैन करने के लिए कैमरे का इस्तेमाल करता है." }, "allowAccess": "कैमरे तक पहुंच की अनुमति दें" + }, + "errors": { + "genericError": "कुछ गलत हो गया। कृपया कुछ समय बाद पुन: प्रयास करें!" } } } \ No newline at end of file diff --git a/locales/kan.json b/locales/kan.json index c00507b4..6822f3d1 100644 --- a/locales/kan.json +++ b/locales/kan.json @@ -366,6 +366,9 @@ "missingPermission": "ಮತ್ತೊಂದು ಸಾಧನದ QR ಕೋಡ್ ಅನ್ನು ಸ್ಕ್ಯಾನ್ ಮಾಡಲು ಈ ಅಪ್ಲಿಕೇಶನ್ ಕ್ಯಾಮರಾವನ್ನು ಬಳಸುತ್ತದೆ." }, "allowAccess": "ಕ್ಯಾಮರಾಗೆ ಪ್ರವೇಶವನ್ನು ಅನುಮತಿಸಿ" + }, + "errors": { + "genericError": "ಏನೋ ತಪ್ಪಾಗಿದೆ. ದಯವಿಟ್ಟು ಸ್ವಲ್ಪ ಸಮಯದ ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ!" } } } \ No newline at end of file diff --git a/locales/tam.json b/locales/tam.json index 434611cf..c8223c0e 100644 --- a/locales/tam.json +++ b/locales/tam.json @@ -365,6 +365,9 @@ "missingPermission": "இந்தப் பயன்பாடு மற்றொரு சாதனத்தின் QR குறியீட்டை ஸ்கேன் செய்ய கேமராவைப் பயன்படுத்துகிறது." }, "allowAccess": "கேமராவை அணுக அனுமதிக்கவும்" + }, + "errors": { + "genericError": "ஏதோ தவறு நடந்துவிட்டது. சிறிது நேரம் கழித்து மீண்டும் முயற்சிக்கவும்!" } } } \ No newline at end of file diff --git a/machines/QrLoginMachine.ts b/machines/QrLoginMachine.ts index 697832c9..e9c414b8 100644 --- a/machines/QrLoginMachine.ts +++ b/machines/QrLoginMachine.ts @@ -15,6 +15,7 @@ import { linkTransactionResponse, VC } from '../types/vc'; import { request } from '../shared/request'; import { getJwt } from '../shared/cryptoutil/cryptoUtil'; import { getPrivateKey } from '../shared/keystore/SecureKeystore'; +import i18n from '../i18n'; const model = createModel( { @@ -286,7 +287,9 @@ export const qrLoginMachine = SetErrorMessage: assign({ errorMessage: (context, event) => - (event as ErrorPlatformEvent).data.message, + i18n.t(`errors.genericError`, { + ns: 'common', + }), }), setConsentClaims: assign({ diff --git a/machines/vcItem.ts b/machines/vcItem.ts index a86b1b38..44154d6b 100644 --- a/machines/vcItem.ts +++ b/machines/vcItem.ts @@ -25,6 +25,7 @@ import { import getAllConfigurations, { DownloadProps, } from '../shared/commonprops/commonProps'; +import i18n from '../i18n'; const model = createModel( { @@ -497,7 +498,10 @@ export const vcItemMachine = { actions: { setWalletBindingError: assign({ - walletBindingError: (context, event) => (event.data as Error).message, + walletBindingError: (context, event) => + i18n.t(`errors.genericError`, { + ns: 'common', + }), }), setWalletBindingErrorEmpty: assign({ diff --git a/screens/Home/MyVcs/AddVcModalMachine.ts b/screens/Home/MyVcs/AddVcModalMachine.ts index fcad62b5..a522180c 100644 --- a/screens/Home/MyVcs/AddVcModalMachine.ts +++ b/screens/Home/MyVcs/AddVcModalMachine.ts @@ -247,7 +247,9 @@ export const AddVcModalMachine = ? i18n.t(`errors.backend.${ID_ERRORS_MAP[message]}`, { ns: 'AddVcModal', }) - : message; + : i18n.t(`errors.genericError`, { + ns: 'common', + }); }, }), diff --git a/shared/request.ts b/shared/request.ts index db0a4d10..b61e0047 100644 --- a/shared/request.ts +++ b/shared/request.ts @@ -24,11 +24,28 @@ export async function request( const jsonResponse = await response.json(); if (response.status >= 400) { - throw new Error(jsonResponse.message || jsonResponse.error); + let backendUrl = HOST + path; + let errorMessage = jsonResponse.message || jsonResponse.error; + console.error( + 'The backend API ' + + backendUrl + + ' returned error code 400 with message --> ' + + errorMessage + ); + throw new Error(errorMessage); } if (jsonResponse.errors && jsonResponse.errors.length) { + let backendUrl = HOST + path; const { errorCode, errorMessage } = jsonResponse.errors.shift(); + console.error( + 'The backend API ' + + backendUrl + + ' returned error response --> error code is : ' + + errorCode + + ' error message is : ' + + errorMessage + ); throw new BackendResponseError(errorCode, errorMessage); }