From 4db720c081ca830db81363e9a8acfd4dddbf9120 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 13 Dec 2023 18:07:00 -0300 Subject: better error msg --- packages/web-util/src/utils/http-impl.sw.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'packages/web-util/src/utils/http-impl.sw.ts') diff --git a/packages/web-util/src/utils/http-impl.sw.ts b/packages/web-util/src/utils/http-impl.sw.ts index 295681b53..3120309f4 100644 --- a/packages/web-util/src/utils/http-impl.sw.ts +++ b/packages/web-util/src/utils/http-impl.sw.ts @@ -182,6 +182,7 @@ function makeJsonHandler( try { responseJson = await response.json(); } catch (e) { + const message = e instanceof Error ? `Invalid JSON from HTTP response: ${e.message}` : "Invalid JSON from HTTP response" throw TalerError.fromDetail( TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE, { @@ -189,7 +190,7 @@ function makeJsonHandler( requestMethod, httpStatusCode: response.status, }, - "Invalid JSON from HTTP response", + message, ); } } @@ -201,7 +202,7 @@ function makeJsonHandler( requestMethod, httpStatusCode: response.status, }, - "Invalid JSON from HTTP response", + "Invalid JSON from HTTP response: null or not object", ); } return responseJson; -- cgit v1.2.3