From 024e97c1760e9e596e58639bb64d6511e7fe8e97 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Tue, 24 Sep 2024 10:53:41 -0300 Subject: [PATCH] fix: 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() {