Skip to content

Commit

Permalink
UIPQB-57 show error message from response (#66)
Browse files Browse the repository at this point in the history
(cherry picked from commit 793ae30)
  • Loading branch information
vashjs committed Nov 10, 2023
1 parent 2e66107 commit 7578801
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ export const QueryBuilderModal = ({
onQueryTestSuccess: () => {
setIsQueryRetrieved(false);
},
onQueryTestFail: () => {
onQueryTestFail: async (err) => {
const response = await err?.response?.json();
const message = response?.message || <FormattedMessage id="ui-plugin-query-builder.error.sww" />;

showCallout({
message: <FormattedMessage id="ui-plugin-query-builder.error.sww" />,
message,
type: 'error',
});
setIsQueryRetrieved(false);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTestQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});

Expand Down

0 comments on commit 7578801

Please sign in to comment.