mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
remove unneeded usages of isErrorResponse (#164609)
`data.search` uses [poll_search](https://github.com/elastic/kibana/blob/main/src/plugins/data/common/search/poll_search.ts) to fetch data. `poll_search` checks for `isErrorResponse` and throws when`isErrorResponse` is true. **Note** `searchSource.search` uses `data.search` to perform searches. ```javascript return from(search()).pipe( expand(() => { const elapsedTime = Date.now() - startTime; return timer(getPollInterval(elapsedTime)).pipe(switchMap(search)); }), tap((response) => { if (isErrorResponse(response)) { throw response ? new Error('Received partial response') : new AbortError(); } }), takeWhile<Response>(isPartialResponse, true), takeUntil<Response>(aborted$) ); ``` Subscribers to `data.search` and `searchSource.search` do not need to check for `isErrorResponse` in `next`. `poll_search` has already thrown then the response is `isErrorResponse` so these checks are dead code blocks that are never executed. This PR removes these dead code blocks. Breaking this change out of https://github.com/elastic/kibana/pull/164506 so that it can be reviewed in isolated. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
5724d01536
commit
0113eb74c8
30 changed files with 56 additions and 257 deletions
|
@ -30,7 +30,6 @@ import {
|
|||
DataPublicPluginStart,
|
||||
IKibanaSearchResponse,
|
||||
isCompleteResponse,
|
||||
isErrorResponse,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import { SearchResponseWarning } from '@kbn/data-plugin/public/search/types';
|
||||
import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
|
||||
|
@ -247,9 +246,6 @@ export const SearchExamplesApp = ({
|
|||
text: toMountPoint(res.warning),
|
||||
});
|
||||
}
|
||||
} else if (isErrorResponse(res)) {
|
||||
// TODO: Make response error status clearer
|
||||
notifications.toasts.addDanger('An error has occurred');
|
||||
}
|
||||
},
|
||||
error: (e) => {
|
||||
|
@ -401,10 +397,6 @@ export const SearchExamplesApp = ({
|
|||
title: 'Query result',
|
||||
text: 'Query finished',
|
||||
});
|
||||
} else if (isErrorResponse(res)) {
|
||||
setIsLoading(false);
|
||||
// TODO: Make response error status clearer
|
||||
notifications.toasts.addWarning('An error has occurred');
|
||||
}
|
||||
},
|
||||
error: (e) => {
|
||||
|
|
|
@ -40,7 +40,6 @@ import {
|
|||
IEsSearchRequest,
|
||||
IEsSearchResponse,
|
||||
isCompleteResponse,
|
||||
isErrorResponse,
|
||||
QueryState,
|
||||
SearchSessionState,
|
||||
} from '@kbn/data-plugin/public';
|
||||
|
@ -724,8 +723,6 @@ function doSearch(
|
|||
title: 'Query result',
|
||||
text: mountReactNode(message),
|
||||
});
|
||||
} else if (isErrorResponse(res)) {
|
||||
notifications.toasts.addWarning('An error has occurred');
|
||||
}
|
||||
}),
|
||||
map((res) => ({ response: res, request: req, tookMs: performance.now() - startTs })),
|
||||
|
|
|
@ -27,7 +27,6 @@ import {
|
|||
DataPublicPluginStart,
|
||||
IKibanaSearchResponse,
|
||||
isCompleteResponse,
|
||||
isErrorResponse,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import {
|
||||
SQL_SEARCH_STRATEGY,
|
||||
|
@ -70,10 +69,6 @@ export const SqlSearchExampleApp = ({ notifications, data }: SearchExamplesAppDe
|
|||
if (isCompleteResponse(res)) {
|
||||
setIsLoading(false);
|
||||
setResponse(res);
|
||||
} else if (isErrorResponse(res)) {
|
||||
setIsLoading(false);
|
||||
setResponse(res);
|
||||
notifications.toasts.addDanger('An error has occurred');
|
||||
}
|
||||
},
|
||||
error: (e) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue