From 5b0ec235cb0e0aa4f36503e1b4b1b51a147a21f4 Mon Sep 17 00:00:00 2001 From: baldo Date: Fri, 26 Aug 2022 18:09:33 +0200 Subject: [PATCH] Fix: Make response body readable in ApiError message. --- frontend/src/utils/Api.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/Api.ts b/frontend/src/utils/Api.ts index 6d77b63..90bb20c 100644 --- a/frontend/src/utils/Api.ts +++ b/frontend/src/utils/Api.ts @@ -53,7 +53,9 @@ export class ApiError extends Error { : await response.text(); return new ApiError( - `API ${method} request failed: ${path} => ${response.status} - ${body}`, + `API ${method} request failed: ${path} => ${ + response.status + } - ${JSON.stringify(body)}`, response.status, ApiErrorType.REQUEST_FAILED, body @@ -67,7 +69,9 @@ export class ApiError extends Error { json: JSONValue ): Promise { return new ApiError( - `API ${method} request result has unexpected type. ${path} => ${json}`, + `API ${method} request result has unexpected type. ${path} => ${JSON.stringify( + json + )}`, response.status, ApiErrorType.UNEXPECTED_RESULT_TYPE, json