From b9951afeac452c2923cc998de47faae409e91623 Mon Sep 17 00:00:00 2001 From: vashjs Date: Fri, 13 Oct 2023 14:25:45 +0100 Subject: [PATCH] UIPQB-57 show error message from response --- .../QueryBuilder/QueryBuilderModal/QueryBuilderModal.js | 6 ++++-- src/hooks/useTestQuery.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js index 89e0447b..81849a98 100644 --- a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js +++ b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js @@ -77,9 +77,11 @@ export const QueryBuilderModal = ({ onQueryTestSuccess: () => { setIsQueryRetrieved(false); }, - onQueryTestFail: () => { + onQueryTestFail: async (err) => { + const { message } = await err.response.json(); + showCallout({ - message: , + message: message || , type: 'error', }); setIsQueryRetrieved(false); diff --git a/src/hooks/useTestQuery.js b/src/hooks/useTestQuery.js index 317239c8..54074401 100644 --- a/src/hooks/useTestQuery.js +++ b/src/hooks/useTestQuery.js @@ -13,9 +13,9 @@ export const useTestQuery = ({ testQueryDataSource, onQueryTestSuccess, onQueryT } = useMutation({ mutationFn: ({ entityTypeId, fqlQuery }) => testQueryDataSource({ entityTypeId, fqlQuery }), onSuccess: onQueryTestSuccess, - onError: () => { + onError: (err) => { setIsTestQueryInProgress(false); - onQueryTestFail(); + onQueryTestFail(err); }, });