Skip to content

Commit

Permalink
simplified error message for user
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
  • Loading branch information
amsiglan committed Oct 11, 2024
1 parent 21e7f86 commit 15ebeef
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/plugins/data/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
*/

import { i18n } from '@osd/i18n';
import {
PollQueryResultsHandler,
FetchStatusResponse,
QueryFailedStatusResponse,
} from '../data_frames';
import { PollQueryResultsHandler, FetchStatusResponse } from '../data_frames';

export interface QueryStatusOptions {
pollQueryResults: PollQueryResultsHandler;
Expand All @@ -46,7 +42,7 @@ export const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
export const handleQueryResults = async <T>(
options: QueryStatusOptions
): Promise<FetchStatusResponse> => {
const { pollQueryResults, interval = 5000, queryId } = options;
const { pollQueryResults, interval = 5000 } = options;
let queryResultsRes: FetchStatusResponse;
let queryStatus;
do {

Check warning on line 48 in src/plugins/data/common/utils/helpers.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/common/utils/helpers.ts#L48

Added line #L48 was not covered by tests
Expand All @@ -57,14 +53,10 @@ export const handleQueryResults = async <T>(
} while (queryStatus !== 'SUCCESS' && queryStatus !== 'FAILED');

if (queryStatus === 'FAILED') {
throw (
(queryResultsRes as QueryFailedStatusResponse).body.error ??
new Error(
i18n.translate('data.search.request.failed', {
defaultMessage: 'Failed to fetch results for queryId: {queryId}',
values: { queryId: queryId ?? '' },
})
)
throw new Error(

Check warning on line 56 in src/plugins/data/common/utils/helpers.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/common/utils/helpers.ts#L56

Added line #L56 was not covered by tests
i18n.translate('data.search.request.failed', {
defaultMessage: 'An error occurred while executing the search query',
})
);
}

Expand Down

0 comments on commit 15ebeef

Please sign in to comment.