diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-04 13:57:56 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-04 13:57:56 +0200 |
commit | 7dd7ff4cebc290b09fe00d82046bb58e4e8a800d (patch) | |
tree | 50769811d4332f107b0db7908e1a9cbe317c19bf /shared/server-commands/requests/requests.ts | |
parent | e37ca6cbc7d20ad773389efa289f8552fa28fc75 (diff) | |
download | PeerTube-7dd7ff4cebc290b09fe00d82046bb58e4e8a800d.tar.gz PeerTube-7dd7ff4cebc290b09fe00d82046bb58e4e8a800d.tar.zst PeerTube-7dd7ff4cebc290b09fe00d82046bb58e4e8a800d.zip |
Fix tests
Diffstat (limited to 'shared/server-commands/requests/requests.ts')
-rw-r--r-- | shared/server-commands/requests/requests.ts | 7 |
1 files changed, 6 insertions, 1 deletions
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> { | |||
134 | function unwrapBodyOrDecodeToJSON <T> (test: request.Test): Promise<T> { | 134 | function unwrapBodyOrDecodeToJSON <T> (test: request.Test): Promise<T> { |
135 | return test.then(res => { | 135 | return test.then(res => { |
136 | if (res.body instanceof Buffer) { | 136 | if (res.body instanceof Buffer) { |
137 | return JSON.parse(new TextDecoder().decode(res.body)) | 137 | try { |
138 | return JSON.parse(new TextDecoder().decode(res.body)) | ||
139 | } catch (err) { | ||
140 | console.error('Cannot decode JSON.', res.body) | ||
141 | throw err | ||
142 | } | ||
138 | } | 143 | } |
139 | 144 | ||
140 | return res.body | 145 | return res.body |