mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML][Transform] display script_exception compile error message in wizards (#97697)
* ensure error rootCause script gets added to message * ensure script part of error is shown in DFA wizard * use isPopulatedObject to check for script field
This commit is contained in:
parent
ee7ba71b43
commit
0a0fd695d3
3 changed files with 16 additions and 1 deletions
|
@ -14,6 +14,7 @@ import {
|
|||
isEsErrorBody,
|
||||
isMLResponseError,
|
||||
} from './types';
|
||||
import { isPopulatedObject } from '../object_utils';
|
||||
|
||||
export const extractErrorProperties = (error: ErrorType): MLErrorObject => {
|
||||
// extract properties of the error object from within the response error
|
||||
|
@ -73,6 +74,14 @@ export const extractErrorProperties = (error: ErrorType): MLErrorObject => {
|
|||
error.body.attributes.body.error.caused_by?.caused_by?.reason ||
|
||||
error.body.attributes.body.error.caused_by?.reason;
|
||||
}
|
||||
if (
|
||||
Array.isArray(error.body.attributes.body.error.root_cause) &&
|
||||
typeof error.body.attributes.body.error.root_cause[0] === 'object' &&
|
||||
isPopulatedObject(error.body.attributes.body.error.root_cause[0], ['script'])
|
||||
) {
|
||||
errObj.causedBy = error.body.attributes.body.error.root_cause[0].script;
|
||||
errObj.message += `: '${error.body.attributes.body.error.root_cause[0].script}'`;
|
||||
}
|
||||
return errObj;
|
||||
} else {
|
||||
return {
|
||||
|
|
|
@ -12,6 +12,7 @@ export interface EsErrorRootCause {
|
|||
type: string;
|
||||
reason: string;
|
||||
caused_by?: EsErrorRootCause;
|
||||
script?: string;
|
||||
}
|
||||
|
||||
export interface EsErrorBody {
|
||||
|
|
|
@ -152,17 +152,22 @@ interface EsError {
|
|||
reason: string;
|
||||
line?: number;
|
||||
col?: number;
|
||||
script?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an error message based on the root cause
|
||||
*/
|
||||
function extractErrorMessage({ type, reason, line, col }: EsError): string {
|
||||
function extractErrorMessage({ type, reason, script, line, col }: EsError): string {
|
||||
let message = `[${type}] ${reason}`;
|
||||
|
||||
if (line !== undefined && col !== undefined) {
|
||||
message += `, with line=${line} & col=${col}`;
|
||||
}
|
||||
|
||||
if (script !== undefined) {
|
||||
message += ` '${script}'`;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue