Browse Source

Improved error display

Arnaud Vergnet 1 year ago
parent
commit
72c5a91f75

+ 7
- 0
src/components/Dialogs/ErrorDialog.js View File

@@ -28,6 +28,12 @@ class ErrorDialog extends React.PureComponent<Props> {
28 28
             case ERROR_TYPE.NO_CONSENT:
29 29
                 this.message = i18n.t("errors.noConsent");
30 30
                 break;
31
+            case ERROR_TYPE.TOKEN_SAVE:
32
+                this.message = i18n.t("errors.tokenSave");
33
+                break;
34
+            case ERROR_TYPE.TOKEN_RETRIEVE:
35
+                this.message = i18n.t("errors.unknown");
36
+                break;
31 37
             case ERROR_TYPE.BAD_INPUT:
32 38
                 this.message = i18n.t("errors.badInput");
33 39
                 break;
@@ -44,6 +50,7 @@ class ErrorDialog extends React.PureComponent<Props> {
44 50
                 this.message = i18n.t("errors.unknown");
45 51
                 break;
46 52
         }
53
+        this.message += "\n\nCode " + this.props.errorCode;
47 54
     }
48 55
 
49 56
     render() {

+ 6
- 0
src/components/Screens/ErrorView.js View File

@@ -45,6 +45,7 @@ class ErrorView extends React.PureComponent<Props, State> {
45 45
     constructor(props) {
46 46
         super(props);
47 47
         this.colors = props.theme.colors;
48
+        this.icon = "";
48 49
     }
49 50
 
50 51
     generateMessage() {
@@ -64,6 +65,10 @@ class ErrorView extends React.PureComponent<Props, State> {
64 65
                     this.message = i18n.t("errors.noConsent");
65 66
                     this.icon = "account-remove-outline";
66 67
                     break;
68
+                case ERROR_TYPE.TOKEN_SAVE:
69
+                    this.message = i18n.t("errors.tokenSave");
70
+                    this.icon = "alert-circle-outline";
71
+                    break;
67 72
                 case ERROR_TYPE.BAD_INPUT:
68 73
                     this.message = i18n.t("errors.badInput");
69 74
                     this.icon = "alert-circle-outline";
@@ -85,6 +90,7 @@ class ErrorView extends React.PureComponent<Props, State> {
85 90
                     this.icon = "alert-circle-outline";
86 91
                     break;
87 92
             }
93
+            this.message += "\n\nCode " + this.props.errorCode;
88 94
         } else {
89 95
             this.message = this.props.message;
90 96
             this.icon = this.props.icon;

+ 2
- 2
src/managers/ConnectionManager.js View File

@@ -122,7 +122,7 @@ export default class ConnectionManager {
122 122
                             resolve(true);
123 123
                         })
124 124
                         .catch(() => {
125
-                            reject(ERROR_TYPE.UNKNOWN);
125
+                            reject(ERROR_TYPE.TOKEN_SAVE);
126 126
                         });
127 127
                 })
128 128
                 .catch((error) => reject(error));
@@ -151,7 +151,7 @@ export default class ConnectionManager {
151 151
                     .then((response) => resolve(response))
152 152
                     .catch((error) => reject(error));
153 153
             } else
154
-                reject(ERROR_TYPE.UNKNOWN);
154
+                reject(ERROR_TYPE.TOKEN_RETRIEVE);
155 155
         });
156 156
     }
157 157
 }

+ 3
- 1
src/utils/WebData.js View File

@@ -5,6 +5,8 @@ export const ERROR_TYPE = {
5 5
     BAD_CREDENTIALS: 1,
6 6
     BAD_TOKEN: 2,
7 7
     NO_CONSENT: 3,
8
+    TOKEN_SAVE: 4,
9
+    TOKEN_RETRIEVE: 5,
8 10
     BAD_INPUT: 400,
9 11
     FORBIDDEN: 403,
10 12
     CONNECTION_ERROR: 404,
@@ -41,7 +43,7 @@ export async function apiRequest(path: string, method: string, params: ?Object)
41 43
                     else
42 44
                         reject(response.error);
43 45
                 } else
44
-                    reject(ERROR_TYPE.CONNECTION_ERROR);
46
+                    reject(ERROR_TYPE.SERVER_ERROR);
45 47
             })
46 48
             .catch(() => {
47 49
                 reject(ERROR_TYPE.CONNECTION_ERROR);

+ 1
- 0
translations/en.json View File

@@ -259,6 +259,7 @@
259 259
     "badCredentials": "Email or password invalid.",
260 260
     "badToken": "You are not logged in. Please login and try again.",
261 261
     "noConsent": "You did not give your consent for data processing to the Amicale.",
262
+    "tokenSave": "Could not save session token. Please contact support.",
262 263
     "badInput": "Invalid input. Please try again.",
263 264
     "forbidden": "You do not have access to this data.",
264 265
     "connectionError": "Network error. Please check your internet connection.",

+ 1
- 0
translations/fr.json View File

@@ -259,6 +259,7 @@
259 259
     "badCredentials": "Email ou mot de passe invalide.",
260 260
     "badToken": "Vous n'êtes pas connecté. Merci de vous connecter puis réessayez.",
261 261
     "noConsent": "Vous n'avez pas donné votre consentement pour l'utilisation de vos données personnelles.",
262
+    "tokenSave": "Impossible de sauvegarder le token de session. Merci de contacter le support.",
262 263
     "badInput": "Entrée invalide. Merci de réessayer.",
263 264
     "forbidden": "Vous n'avez pas accès à cette information.",
264 265
     "connectionError": "Erreur de réseau. Merci de vérifier votre connexion Internet.",

Loading…
Cancel
Save