forked from vergnet/application-amicale
Improved error handling
This commit is contained in:
parent
4259dd779d
commit
2b0945fe5b
1 changed files with 20 additions and 3 deletions
|
@ -11,7 +11,7 @@ import {
|
||||||
View
|
View
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import {Avatar, Button, Card, HelperText, Text, TextInput, withTheme} from 'react-native-paper';
|
import {Avatar, Button, Card, HelperText, Text, TextInput, withTheme} from 'react-native-paper';
|
||||||
import ConnectionManager from "../../managers/ConnectionManager";
|
import ConnectionManager, {ERROR_TYPE} from "../../managers/ConnectionManager";
|
||||||
import {openBrowser} from "../../utils/WebBrowser";
|
import {openBrowser} from "../../utils/WebBrowser";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -125,8 +125,7 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
Alert.alert('COOL', 'ÇA MARCHE');
|
Alert.alert('COOL', 'ÇA MARCHE');
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error);
|
this.handleErrors(error);
|
||||||
Alert.alert('ERREUR', 'MDP OU MAIL INVALIDE');
|
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.setState({loading: false});
|
this.setState({loading: false});
|
||||||
|
@ -134,6 +133,24 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleErrors(error: number) {
|
||||||
|
switch (error) {
|
||||||
|
case ERROR_TYPE.CONNECTION_ERROR:
|
||||||
|
Alert.alert('ERREUR', 'PB DE CONNEXION');
|
||||||
|
break;
|
||||||
|
case ERROR_TYPE.BAD_CREDENTIALS:
|
||||||
|
Alert.alert('ERREUR', 'MDP OU MAIL INVALIDE');
|
||||||
|
break;
|
||||||
|
case ERROR_TYPE.SAVE_TOKEN:
|
||||||
|
Alert.alert('ERREUR', 'IMPOSSIBLE DE SAUVEGARDER INFOS CONNEXION');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Alert.alert('ERREUR', 'ERREUR INCONNUE. CONTACTER ARNAUD');
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getFormInput() {
|
getFormInput() {
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
|
|
Loading…
Reference in a new issue