Skip to content

Commit

Permalink
[ILM] Add comments about legacy and new es js client
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliacech committed Oct 15, 2020
1 parent 92d703e commit 268d165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ interface EsErrorHandlerParams {
error: ApiError;
response: KibanaResponseFactory;
}

/*
* For errors returned by the new elasticsearch js client.
*/
export const handleEsError = ({ error, response }: EsErrorHandlerParams): IKibanaResponse => {
// error.name is slightly better in terms of performance, since all errors now have name property
if (error.name === 'ResponseError') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ interface RequestError extends Error {
statusCode?: number;
}

/*
* @deprecated
* Only works with legacy elasticsearch js client errors and will be removed after 7.x last
*/
export function isEsError(err: RequestError) {
const isInstanceOfEsError = err instanceof esErrorsParent;
const hasStatusCode = Boolean(err.statusCode);
Expand Down

0 comments on commit 268d165

Please sign in to comment.