-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9027b2a
commit 430dbdb
Showing
7 changed files
with
98 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { MLRequestFailure } from './request_error'; | ||
export { extractErrorMessage, extractErrorProperties } from './process_errors'; | ||
export { | ||
ErrorType, | ||
EsErrorBody, | ||
EsErrorRootCause, | ||
MLErrorObject, | ||
MLHttpFetchError, | ||
MLResponseError, | ||
isBoomError, | ||
isErrorString, | ||
isEsErrorBody, | ||
isMLResponseError, | ||
} from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { HttpFetchError } from 'kibana/public'; | ||
import Boom from 'boom'; | ||
|
||
export interface EsErrorRootCause { | ||
type: string; | ||
reason: string; | ||
} | ||
|
||
export interface EsErrorBody { | ||
error: { | ||
root_cause?: EsErrorRootCause[]; | ||
type: string; | ||
reason: string; | ||
}; | ||
status: number; | ||
} | ||
|
||
export interface MLResponseError { | ||
statusCode: number; | ||
error: string; | ||
message: string; | ||
attributes?: { | ||
body: EsErrorBody; | ||
}; | ||
} | ||
|
||
export interface MLErrorObject { | ||
message: string; | ||
statusCode?: number; | ||
fullError?: EsErrorBody; | ||
} | ||
|
||
export interface MLHttpFetchError<T> extends HttpFetchError { | ||
body: T; | ||
} | ||
|
||
export type ErrorType = MLHttpFetchError<MLResponseError> | EsErrorBody | Boom | string | undefined; | ||
|
||
export function isEsErrorBody(error: any): error is EsErrorBody { | ||
return error && error.error?.reason !== undefined; | ||
} | ||
|
||
export function isErrorString(error: any): error is string { | ||
return typeof error === 'string'; | ||
} | ||
|
||
export function isMLResponseError(error: any): error is MLResponseError { | ||
return typeof error.body === 'object' && 'message' in error.body; | ||
} | ||
|
||
export function isBoomError(error: any): error is Boom { | ||
return error.isBoom === true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters