-
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.
[ML] Improving client side error handling (#76743)
* [ML] Improving client side error handling * adding stacktrace to request errors * copying error parsing to transforms * update snapshot * fixing jest tests * adding test and removing debug log output * updating translations * rewriting error extracting code * fixing tests * removing message bar service * removing test code * updating translations * combining job creation error handling * refactoring error files * updating test * fixing bug in DFA deletion * improving mml warning Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
22b4e40
commit ea8086b
Showing
61 changed files
with
591 additions
and
939 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,99 @@ | ||
/* | ||
* 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 Boom from 'boom'; | ||
|
||
import { extractErrorMessage, MLHttpFetchError, MLResponseError, EsErrorBody } from './index'; | ||
|
||
describe('ML - error message utils', () => { | ||
describe('extractErrorMessage', () => { | ||
test('returns just the error message', () => { | ||
const testMsg = 'Saved object [index-pattern/indexpattern] not found'; | ||
|
||
// bad error, return empty string | ||
const badError = {} as any; | ||
expect(extractErrorMessage(badError)).toBe(''); | ||
|
||
// raw es error | ||
const esErrorMsg: EsErrorBody = { | ||
error: { | ||
root_cause: [ | ||
{ | ||
type: 'type', | ||
reason: 'reason', | ||
}, | ||
], | ||
type: 'type', | ||
reason: testMsg, | ||
}, | ||
status: 404, | ||
}; | ||
expect(extractErrorMessage(esErrorMsg)).toBe(testMsg); | ||
|
||
// error is basic string | ||
const stringMessage = testMsg; | ||
expect(extractErrorMessage(stringMessage)).toBe(testMsg); | ||
|
||
// kibana error without attributes | ||
const bodyWithoutAttributes: MLHttpFetchError<MLResponseError> = { | ||
name: 'name', | ||
req: {} as Request, | ||
request: {} as Request, | ||
message: 'Something else', | ||
body: { | ||
statusCode: 404, | ||
error: 'error', | ||
message: testMsg, | ||
}, | ||
}; | ||
expect(extractErrorMessage(bodyWithoutAttributes)).toBe(testMsg); | ||
|
||
// kibana error with attributes | ||
const bodyWithAttributes: MLHttpFetchError<MLResponseError> = { | ||
name: 'name', | ||
req: {} as Request, | ||
request: {} as Request, | ||
message: 'Something else', | ||
body: { | ||
statusCode: 404, | ||
error: 'error', | ||
message: 'Something else', | ||
attributes: { | ||
body: { | ||
status: 404, | ||
error: { | ||
reason: testMsg, | ||
type: 'type', | ||
root_cause: [{ type: 'type', reason: 'reason' }], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
expect(extractErrorMessage(bodyWithAttributes)).toBe(testMsg); | ||
|
||
// boom error | ||
const boomError: Boom<any> = { | ||
message: '', | ||
reformat: () => '', | ||
name: '', | ||
data: [], | ||
isBoom: true, | ||
isServer: false, | ||
output: { | ||
statusCode: 404, | ||
payload: { | ||
statusCode: 404, | ||
error: testMsg, | ||
message: testMsg, | ||
}, | ||
headers: {}, | ||
}, | ||
}; | ||
expect(extractErrorMessage(boomError)).toBe(testMsg); | ||
}); | ||
}); | ||
}); |
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'; |
Oops, something went wrong.