mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
parent
c3c161e29a
commit
6819311ec8
2 changed files with 15 additions and 0 deletions
|
@ -47,6 +47,10 @@ export function convertEsError(indices, error) {
|
|||
return createNoMatchingIndicesError(indices);
|
||||
}
|
||||
|
||||
if (error.isBoom) {
|
||||
return error;
|
||||
}
|
||||
|
||||
const statusCode = error.statusCode;
|
||||
const message = error.body ? error.body.error : undefined;
|
||||
return Boom.wrap(error, statusCode, message);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import expect from 'expect.js';
|
||||
import { errors as esErrors } from 'elasticsearch';
|
||||
import Boom from 'boom';
|
||||
|
||||
import {
|
||||
isEsIndexNotFoundError,
|
||||
|
@ -106,6 +107,16 @@ export default function ({ getService }) {
|
|||
expect(converted).to.have.property('isBoom');
|
||||
expect(converted.output.statusCode).to.be(403);
|
||||
});
|
||||
|
||||
it('handles errors that are already Boom errors', () => {
|
||||
const error = new Error();
|
||||
error.statusCode = 401;
|
||||
const boomError = Boom.wrap(error, error.statusCode);
|
||||
|
||||
const converted = convertEsError(indices, boomError);
|
||||
|
||||
expect(converted.output.statusCode).to.be(401);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue