From 969f960d8be2cfac75639c005369219cd9235937 Mon Sep 17 00:00:00 2001 From: Pauline <4224001+paulineribeyre@users.noreply.github.com> Date: Wed, 25 May 2022 11:48:42 -0500 Subject: [PATCH] catch error --- src/components/Utils/queries.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Utils/queries.js b/src/components/Utils/queries.js index 7cb4948b..fb519463 100644 --- a/src/components/Utils/queries.js +++ b/src/components/Utils/queries.js @@ -398,7 +398,12 @@ export const askGuppyForTotalCounts = ( }, body: JSON.stringify(queryBody), }).then((response) => response.json()) - .then((response) => response.data._aggregation[type]._totalCount) + .then((response) => { + if (response.errors) { + throw new Error(`Error during download ${response.errors}`); + } + return response.data._aggregation[type]._totalCount; + }) .catch((err) => { throw new Error(`Error during download ${err}`); });