mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-01 02:09:04 +02:00
Merge with remote
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user