From ec678de4ad6f4a7fc68815ba3f7a6d6971b9ae4b Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Tue, 24 Sep 2024 10:53:41 -0300 Subject: [PATCH] lib: handle errors on H1 fetch reports --- lib/request.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/request.js b/lib/request.js index a4b43586..2c0e1a5e 100644 --- a/lib/request.js +++ b/lib/request.js @@ -158,7 +158,13 @@ export default class Request { Accept: 'application/json' } }; - return this.json(url, options); + const data = await this.json(url, options); + if (data?.errors) { + throw new Error( + `Request to fetch triaged reports failed with: ${JSON.stringify(data.errors)}` + ); + } + return data; } async getPrograms() {