mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
ensure missing indexPattern error is bubbled up to error callout (#79378)
This commit is contained in:
parent
1e36e275ca
commit
9794188cbf
3 changed files with 17 additions and 1 deletions
|
@ -8,6 +8,7 @@ export { MLRequestFailure } from './request_error';
|
|||
export { extractErrorMessage, extractErrorProperties } from './process_errors';
|
||||
export {
|
||||
ErrorType,
|
||||
ErrorMessage,
|
||||
EsErrorBody,
|
||||
EsErrorRootCause,
|
||||
MLErrorObject,
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
MLErrorObject,
|
||||
isBoomError,
|
||||
isErrorString,
|
||||
isErrorMessage,
|
||||
isEsErrorBody,
|
||||
isMLResponseError,
|
||||
} from './types';
|
||||
|
@ -40,7 +41,7 @@ export const extractErrorProperties = (error: ErrorType): MLErrorObject => {
|
|||
};
|
||||
}
|
||||
|
||||
if (error?.body === undefined) {
|
||||
if (error?.body === undefined && !error?.message) {
|
||||
return {
|
||||
message: '',
|
||||
};
|
||||
|
@ -70,6 +71,12 @@ export const extractErrorProperties = (error: ErrorType): MLErrorObject => {
|
|||
}
|
||||
}
|
||||
|
||||
if (isErrorMessage(error)) {
|
||||
return {
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
|
||||
// If all else fail return an empty message instead of JSON.stringify
|
||||
return {
|
||||
message: '',
|
||||
|
|
|
@ -31,6 +31,10 @@ export interface MLResponseError {
|
|||
};
|
||||
}
|
||||
|
||||
export interface ErrorMessage {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface MLErrorObject {
|
||||
message: string;
|
||||
statusCode?: number;
|
||||
|
@ -51,6 +55,10 @@ export function isErrorString(error: any): error is string {
|
|||
return typeof error === 'string';
|
||||
}
|
||||
|
||||
export function isErrorMessage(error: any): error is ErrorMessage {
|
||||
return error && error.message !== undefined && typeof error.message === 'string';
|
||||
}
|
||||
|
||||
export function isMLResponseError(error: any): error is MLResponseError {
|
||||
return typeof error.body === 'object' && 'message' in error.body;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue