Skip to content

Commit

Permalink
propagate errorr
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 13, 2023
1 parent a7940aa commit b009aa9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,27 @@ export const QueryBuilderModal = ({
setIsPreviewLoading,
isTestQueryInProgress,
setIsTestQueryInProgress,
failureReason,
error,
} = useTestQuery({
testQueryDataSource,
onQueryTestSuccess: () => {
setIsQueryRetrieved(false);
},
onQueryTestFail: (error) => {
onQueryTestFail: (err, variables) => {
console.log(variables);

Check warning on line 83 in src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Unexpected console statement

showCallout({
message: error.message || <FormattedMessage id="ui-plugin-query-builder.error.sww" />,
message: err.message || <FormattedMessage id="ui-plugin-query-builder.error.sww" />,
type: 'error',
});
setIsQueryRetrieved(false);
},
});

console.log(failureReason);

Check warning on line 93 in src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Unexpected console statement
console.log(error);

Check warning on line 94 in src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Unexpected console statement

const { runQuery, isRunQueryLoading } = useRunQuery({
onQueryRunSuccess,
queryId,
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useTestQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export const useTestQuery = ({ testQueryDataSource, onQueryTestSuccess, onQueryT
mutateAsync: testQuery,
reset: resetTestQuery,
isLoading: isTestQueryLoading,
failureReason,
error,
} = useMutation({
mutationFn: ({ entityTypeId, fqlQuery }) => testQueryDataSource({ entityTypeId, fqlQuery }),
onSuccess: onQueryTestSuccess,
onError: (error) => {
onError: (err, variables) => {
setIsTestQueryInProgress(false);
onQueryTestFail(error);
onQueryTestFail(err, variables);
},
});

Expand All @@ -30,5 +32,7 @@ export const useTestQuery = ({ testQueryDataSource, onQueryTestSuccess, onQueryT
setIsPreviewLoading,
isTestQueryInProgress,
setIsTestQueryInProgress,
failureReason,
error,
};
};

0 comments on commit b009aa9

Please sign in to comment.