wrap login call in try/catch for error handling

This commit is contained in:
ayan4m1 2023-06-15 08:48:54 -04:00 committed by Andrew DeLisa
parent e0cc7ba3c3
commit 55512a2eae

View file

@ -160,6 +160,7 @@ export class Login extends Component<any, State> {
if (username_or_email && password) { if (username_or_email && password) {
i.setState({ loginRes: { state: "loading" } }); i.setState({ loginRes: { state: "loading" } });
try {
const loginRes = await HttpService.client.login({ const loginRes = await HttpService.client.login({
username_or_email, username_or_email,
password, password,
@ -193,6 +194,9 @@ export class Login extends Component<any, State> {
break; break;
} }
} }
} catch (error) {
i.setState({ loginRes: { state: "failed", msg: error.message } });
}
} }
} }