From 23c854dc9a14a2ec21c88e38654e552993569d6f Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sun, 7 Jun 2020 01:00:46 +0200 Subject: [PATCH] Throw error if unexpected response code Signed-off-by: Tilman Vatteroth --- src/utils/apiUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/apiUtils.ts b/src/utils/apiUtils.ts index d2378b85a..dff5a30b1 100644 --- a/src/utils/apiUtils.ts +++ b/src/utils/apiUtils.ts @@ -16,6 +16,8 @@ export const getBackendUrl: (() => string) = () => { return store.getState().frontendConfig.backendUrl } -export const expectResponseCode = (response: Response, code = 200): boolean => { - return response.status !== code +export const expectResponseCode = (response: Response, code = 200): void => { + if (response.status !== code) { + throw new Error(`response code is not ${code}`) + } }