improve error handling in the ui

This commit is contained in:
Sebastian Sdorra
2018-11-15 21:39:08 +01:00
parent 51c9a4dbb2
commit a4d78e6e60
13 changed files with 275 additions and 63 deletions

View File

@@ -2,7 +2,7 @@
import type { Me } from "@scm-manager/ui-types";
import * as types from "./types";
import { apiClient, UNAUTHORIZED_ERROR } from "@scm-manager/ui-components";
import { apiClient, UnauthorizedError } from "@scm-manager/ui-components";
import { isPending } from "./pending";
import { getFailure } from "./failure";
import {
@@ -159,7 +159,7 @@ export const login = (
dispatch(loginPending());
return apiClient
.post(loginLink, login_data)
.then(response => {
.then(() => {
dispatch(fetchIndexResourcesPending());
return callFetchIndexResources();
})
@@ -185,7 +185,7 @@ export const fetchMe = (link: string) => {
dispatch(fetchMeSuccess(me));
})
.catch((error: Error) => {
if (error === UNAUTHORIZED_ERROR) {
if (error instanceof UnauthorizedError) {
dispatch(fetchMeUnauthenticated());
} else {
dispatch(fetchMeFailure(error));