mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 21:33:59 -05:00
Throw error if unexpected response code
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
8c4621ec97
commit
23c854dc9a
1 changed files with 4 additions and 2 deletions
|
@ -16,6 +16,8 @@ export const getBackendUrl: (() => string) = () => {
|
||||||
return store.getState().frontendConfig.backendUrl
|
return store.getState().frontendConfig.backendUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
export const expectResponseCode = (response: Response, code = 200): boolean => {
|
export const expectResponseCode = (response: Response, code = 200): void => {
|
||||||
return response.status !== code
|
if (response.status !== code) {
|
||||||
|
throw new Error(`response code is not ${code}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue