mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Saved Objects Client handle RequestEntityTooLarge error from Elasticsearch * remove console log
This commit is contained in:
parent
8411c02579
commit
48fdc0f51e
3 changed files with 24 additions and 0 deletions
|
@ -28,6 +28,7 @@ const {
|
|||
Conflict,
|
||||
401: NotAuthorized,
|
||||
403: Forbidden,
|
||||
413: RequestEntityTooLarge,
|
||||
NotFound,
|
||||
BadRequest
|
||||
} = elasticsearch.errors;
|
||||
|
@ -36,6 +37,7 @@ import {
|
|||
decorateBadRequestError,
|
||||
decorateNotAuthorizedError,
|
||||
decorateForbiddenError,
|
||||
decorateRequestEntityTooLargeError,
|
||||
createGenericNotFoundError,
|
||||
decorateConflictError,
|
||||
decorateEsUnavailableError,
|
||||
|
@ -69,6 +71,10 @@ export function decorateEsError(error) {
|
|||
return decorateForbiddenError(error, reason);
|
||||
}
|
||||
|
||||
if (error instanceof RequestEntityTooLarge) {
|
||||
return decorateRequestEntityTooLargeError(error, reason);
|
||||
}
|
||||
|
||||
if (error instanceof NotFound) {
|
||||
return createGenericNotFoundError();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
isConflictError,
|
||||
isNotAuthorizedError,
|
||||
isForbiddenError,
|
||||
isRequestEntityTooLargeError,
|
||||
isNotFoundError,
|
||||
isBadRequestError,
|
||||
} from './errors';
|
||||
|
@ -84,6 +85,13 @@ describe('savedObjectsClient/decorateEsError', () => {
|
|||
expect(isForbiddenError(error)).toBe(true);
|
||||
});
|
||||
|
||||
it('makes es.RequestEntityTooLarge a SavedObjectsClient/RequestEntityTooLarge error', () => {
|
||||
const error = new esErrors.RequestEntityTooLarge();
|
||||
expect(isRequestEntityTooLargeError(error)).toBe(false);
|
||||
expect(decorateEsError(error)).toBe(error);
|
||||
expect(isRequestEntityTooLargeError(error)).toBe(true);
|
||||
});
|
||||
|
||||
it('discards es.NotFound errors and returns a generic NotFound error', () => {
|
||||
const error = new esErrors.NotFound();
|
||||
expect(isNotFoundError(error)).toBe(false);
|
||||
|
|
|
@ -71,6 +71,16 @@ export function isForbiddenError(error) {
|
|||
}
|
||||
|
||||
|
||||
// 413 - Request Entity Too Large
|
||||
const CODE_REQUEST_ENTITY_TOO_LARGE = 'SavedObjectsClient/requestEntityTooLarge';
|
||||
export function decorateRequestEntityTooLargeError(error, reason) {
|
||||
return decorate(error, CODE_REQUEST_ENTITY_TOO_LARGE, 413, reason);
|
||||
}
|
||||
export function isRequestEntityTooLargeError(error) {
|
||||
return error && error[code] === CODE_REQUEST_ENTITY_TOO_LARGE;
|
||||
}
|
||||
|
||||
|
||||
// 404 - Not Found
|
||||
const CODE_NOT_FOUND = 'SavedObjectsClient/notFound';
|
||||
export function createGenericNotFoundError(type = null, id = null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue