improvement: better error handling

This commit is contained in:
canove
2020-09-04 17:09:39 -03:00
parent 3cb3fc1a20
commit f7fe3286b8
23 changed files with 166 additions and 532 deletions

View File

@@ -35,7 +35,10 @@ const useAuth = () => {
} catch (err) {
setLoading(false);
setIsAuth(false);
toast.error(i18n.t("auth.toasts.fail"));
console.log(err);
if (err.response && err.response.data && err.response.data.error) {
toast.error(err.response.data.error);
}
}
};
checkAuth();
@@ -53,7 +56,10 @@ const useAuth = () => {
toast.success(i18n.t("auth.toasts.success"));
history.push("/tickets");
} catch (err) {
toast.error(i18n.t("auth.toasts.fail"));
console.log(err);
if (err.response && err.response.data && err.response.data.error) {
toast.error(err.response.data.error);
}
}
};