forked from vergnet/application-amicale
Improved error display
This commit is contained in:
parent
6ac459e58a
commit
72c5a91f75
6 changed files with 20 additions and 3 deletions
|
@ -28,6 +28,12 @@ class ErrorDialog extends React.PureComponent<Props> {
|
|||
case ERROR_TYPE.NO_CONSENT:
|
||||
this.message = i18n.t("errors.noConsent");
|
||||
break;
|
||||
case ERROR_TYPE.TOKEN_SAVE:
|
||||
this.message = i18n.t("errors.tokenSave");
|
||||
break;
|
||||
case ERROR_TYPE.TOKEN_RETRIEVE:
|
||||
this.message = i18n.t("errors.unknown");
|
||||
break;
|
||||
case ERROR_TYPE.BAD_INPUT:
|
||||
this.message = i18n.t("errors.badInput");
|
||||
break;
|
||||
|
@ -44,6 +50,7 @@ class ErrorDialog extends React.PureComponent<Props> {
|
|||
this.message = i18n.t("errors.unknown");
|
||||
break;
|
||||
}
|
||||
this.message += "\n\nCode " + this.props.errorCode;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -45,6 +45,7 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.colors = props.theme.colors;
|
||||
this.icon = "";
|
||||
}
|
||||
|
||||
generateMessage() {
|
||||
|
@ -64,6 +65,10 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
this.message = i18n.t("errors.noConsent");
|
||||
this.icon = "account-remove-outline";
|
||||
break;
|
||||
case ERROR_TYPE.TOKEN_SAVE:
|
||||
this.message = i18n.t("errors.tokenSave");
|
||||
this.icon = "alert-circle-outline";
|
||||
break;
|
||||
case ERROR_TYPE.BAD_INPUT:
|
||||
this.message = i18n.t("errors.badInput");
|
||||
this.icon = "alert-circle-outline";
|
||||
|
@ -85,6 +90,7 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
this.icon = "alert-circle-outline";
|
||||
break;
|
||||
}
|
||||
this.message += "\n\nCode " + this.props.errorCode;
|
||||
} else {
|
||||
this.message = this.props.message;
|
||||
this.icon = this.props.icon;
|
||||
|
|
|
@ -122,7 +122,7 @@ export default class ConnectionManager {
|
|||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(ERROR_TYPE.UNKNOWN);
|
||||
reject(ERROR_TYPE.TOKEN_SAVE);
|
||||
});
|
||||
})
|
||||
.catch((error) => reject(error));
|
||||
|
@ -151,7 +151,7 @@ export default class ConnectionManager {
|
|||
.then((response) => resolve(response))
|
||||
.catch((error) => reject(error));
|
||||
} else
|
||||
reject(ERROR_TYPE.UNKNOWN);
|
||||
reject(ERROR_TYPE.TOKEN_RETRIEVE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ export const ERROR_TYPE = {
|
|||
BAD_CREDENTIALS: 1,
|
||||
BAD_TOKEN: 2,
|
||||
NO_CONSENT: 3,
|
||||
TOKEN_SAVE: 4,
|
||||
TOKEN_RETRIEVE: 5,
|
||||
BAD_INPUT: 400,
|
||||
FORBIDDEN: 403,
|
||||
CONNECTION_ERROR: 404,
|
||||
|
@ -41,7 +43,7 @@ export async function apiRequest(path: string, method: string, params: ?Object)
|
|||
else
|
||||
reject(response.error);
|
||||
} else
|
||||
reject(ERROR_TYPE.CONNECTION_ERROR);
|
||||
reject(ERROR_TYPE.SERVER_ERROR);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(ERROR_TYPE.CONNECTION_ERROR);
|
||||
|
|
|
@ -259,6 +259,7 @@
|
|||
"badCredentials": "Email or password invalid.",
|
||||
"badToken": "You are not logged in. Please login and try again.",
|
||||
"noConsent": "You did not give your consent for data processing to the Amicale.",
|
||||
"tokenSave": "Could not save session token. Please contact support.",
|
||||
"badInput": "Invalid input. Please try again.",
|
||||
"forbidden": "You do not have access to this data.",
|
||||
"connectionError": "Network error. Please check your internet connection.",
|
||||
|
|
|
@ -259,6 +259,7 @@
|
|||
"badCredentials": "Email ou mot de passe invalide.",
|
||||
"badToken": "Vous n'êtes pas connecté. Merci de vous connecter puis réessayez.",
|
||||
"noConsent": "Vous n'avez pas donné votre consentement pour l'utilisation de vos données personnelles.",
|
||||
"tokenSave": "Impossible de sauvegarder le token de session. Merci de contacter le support.",
|
||||
"badInput": "Entrée invalide. Merci de réessayer.",
|
||||
"forbidden": "Vous n'avez pas accès à cette information.",
|
||||
"connectionError": "Erreur de réseau. Merci de vérifier votre connexion Internet.",
|
||||
|
|
Loading…
Reference in a new issue