From cc11f56bfa57066da1730306a580070e712fa80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Mon, 10 Dec 2018 08:11:09 +0100 Subject: [PATCH 1/2] use new created error to fix test --- scm-ui/src/modules/auth.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scm-ui/src/modules/auth.js b/scm-ui/src/modules/auth.js index 489f701a74..e9bccb8fbc 100644 --- a/scm-ui/src/modules/auth.js +++ b/scm-ui/src/modules/auth.js @@ -2,10 +2,7 @@ import type { Me } from "@scm-manager/ui-types"; import * as types from "./types"; -import { - apiClient, - UNAUTHORIZED_ERROR_MESSAGE -} from "@scm-manager/ui-components"; +import { apiClient, UNAUTHORIZED_ERROR } from "@scm-manager/ui-components"; import { isPending } from "./pending"; import { getFailure } from "./failure"; import { @@ -190,7 +187,7 @@ export const fetchMe = (link: string) => { dispatch(fetchMeSuccess(me)); }) .catch((error: Error) => { - if (error.message === UNAUTHORIZED_ERROR_MESSAGE) { + if (error === UNAUTHORIZED_ERROR) { dispatch(fetchMeUnauthenticated()); } else { dispatch(fetchMeFailure(error)); From 040035e0843d1aa134095ae1c69afd44c54350e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Mon, 10 Dec 2018 08:42:29 +0100 Subject: [PATCH 2/2] renaming --- .../packages/ui-components/src/apiclient.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/apiclient.js b/scm-ui-components/packages/ui-components/src/apiclient.js index 0cabb9429e..8c4bde6a72 100644 --- a/scm-ui-components/packages/ui-components/src/apiclient.js +++ b/scm-ui-components/packages/ui-components/src/apiclient.js @@ -16,20 +16,20 @@ function handleStatusCode(response: Response) { if (!response.ok) { switch (response.status) { case 401: - return throwErrorWithMessage(response, UNAUTHORIZED_ERROR); + return throwError(response, UNAUTHORIZED_ERROR); case 404: - return throwErrorWithMessage(response, NOT_FOUND_ERROR); + return throwError(response, NOT_FOUND_ERROR); case 409: - return throwErrorWithMessage(response, CONFLICT_ERROR); + return throwError(response, CONFLICT_ERROR); default: - return throwErrorWithMessage(response, new Error("server returned status code " + response.status)); + return throwError(response, new Error("server returned status code " + response.status)); } } return response; } -function throwErrorWithMessage(response: Response, err: Error) { +function throwError(response: Response, err: Error) { return response.json().then( json => { throw Error(json.message);