From 98b482c4955a2ae99e043ff13a2b8b8227bdaa41 Mon Sep 17 00:00:00 2001 From: DopiGFX Date: Mon, 16 Sep 2024 19:22:50 +0200 Subject: [PATCH] fix(deserializer): try-catch, to prevent parsing non deserializable responses --- src/serialization/DefaultResponseDeserializer.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/serialization/DefaultResponseDeserializer.ts b/src/serialization/DefaultResponseDeserializer.ts index b4d1fce..abd1098 100644 --- a/src/serialization/DefaultResponseDeserializer.ts +++ b/src/serialization/DefaultResponseDeserializer.ts @@ -5,8 +5,12 @@ export default class DefaultResponseDeserializer implements IResponseDeserialize const text = await response.text(); if (text.length > 0) { - const json = JSON.parse(text); - return json as TReturnType; + try { + const json = JSON.parse(text); + return json as TReturnType; + } catch (error) { + //This error is thrown falsely, no log needed + } } return null as TReturnType;