From 7dd7ff4cebc290b09fe00d82046bb58e4e8a800d Mon Sep 17 00:00:00 2001
From: Chocobozzz <me@florianbigard.com>
Date: Tue, 4 Oct 2022 13:57:56 +0200
Subject: Fix tests

---
 shared/server-commands/requests/requests.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'shared/server-commands/requests')

diff --git a/shared/server-commands/requests/requests.ts b/shared/server-commands/requests/requests.ts
index 85cbc9be9..8cc1245e0 100644
--- a/shared/server-commands/requests/requests.ts
+++ b/shared/server-commands/requests/requests.ts
@@ -134,7 +134,12 @@ function unwrapText (test: request.Test): Promise<string> {
 function unwrapBodyOrDecodeToJSON <T> (test: request.Test): Promise<T> {
   return test.then(res => {
     if (res.body instanceof Buffer) {
-      return JSON.parse(new TextDecoder().decode(res.body))
+      try {
+        return JSON.parse(new TextDecoder().decode(res.body))
+      } catch (err) {
+        console.error('Cannot decode JSON.', res.body)
+        throw err
+      }
     }
 
     return res.body
-- 
cgit v1.2.3