mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Saved Objects Client] Return info about what was missing in the 404 (#19868)
* [Saved Objects Client] Return info about what was missing in the 404 error * update api integration tests * fix another test
This commit is contained in:
parent
bdebff91fb
commit
633aa4250f
5 changed files with 13 additions and 10 deletions
|
@ -73,7 +73,10 @@ export function isForbiddenError(error) {
|
|||
|
||||
// 404 - Not Found
|
||||
const CODE_NOT_FOUND = 'SavedObjectsClient/notFound';
|
||||
export function createGenericNotFoundError() {
|
||||
export function createGenericNotFoundError(type = null, id = null) {
|
||||
if (type && id) {
|
||||
return decorate(Boom.notFound(`Saved object [${type}/${id}] not found`), CODE_NOT_FOUND, 404);
|
||||
}
|
||||
return decorate(Boom.notFound(), CODE_NOT_FOUND, 404);
|
||||
}
|
||||
export function isNotFoundError(error) {
|
||||
|
|
|
@ -193,7 +193,7 @@ export class SavedObjectsRepository {
|
|||
const indexNotFound = response.error && response.error.type === 'index_not_found_exception';
|
||||
if (docNotFound || indexNotFound) {
|
||||
// see "404s from missing index" above
|
||||
throw errors.createGenericNotFoundError();
|
||||
throw errors.createGenericNotFoundError(type, id);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
|
@ -352,7 +352,7 @@ export class SavedObjectsRepository {
|
|||
const indexNotFound = response.status === 404;
|
||||
if (docNotFound || indexNotFound) {
|
||||
// see "404s from missing index" above
|
||||
throw errors.createGenericNotFoundError();
|
||||
throw errors.createGenericNotFoundError(type, id);
|
||||
}
|
||||
|
||||
const { updated_at: updatedAt } = response._source;
|
||||
|
@ -394,7 +394,7 @@ export class SavedObjectsRepository {
|
|||
|
||||
if (response.status === 404) {
|
||||
// see "404s from missing index" above
|
||||
throw errors.createGenericNotFoundError();
|
||||
throw errors.createGenericNotFoundError(type, id);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -46,7 +46,7 @@ export default function ({ getService }) {
|
|||
expect(resp.body).to.eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: 'Not Found'
|
||||
message: 'Saved object [dashboard/not-a-real-id] not found'
|
||||
});
|
||||
})
|
||||
));
|
||||
|
@ -69,7 +69,7 @@ export default function ({ getService }) {
|
|||
expect(resp.body).to.eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: 'Not Found'
|
||||
message: 'Saved object [dashboard/be3733a0-9efe-11e7-acb3-3dab96693fab] not found'
|
||||
});
|
||||
})
|
||||
));
|
||||
|
|
|
@ -60,7 +60,7 @@ export default function ({ getService }) {
|
|||
.then(resp => {
|
||||
expect(resp.body).to.eql({
|
||||
error: 'Not Found',
|
||||
message: 'Not Found',
|
||||
message: 'Saved object [visualization/foobar] not found',
|
||||
statusCode: 404,
|
||||
});
|
||||
})
|
||||
|
@ -84,7 +84,7 @@ export default function ({ getService }) {
|
|||
.then(resp => {
|
||||
expect(resp.body).to.eql({
|
||||
error: 'Not Found',
|
||||
message: 'Not Found',
|
||||
message: 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] not found',
|
||||
statusCode: 404,
|
||||
});
|
||||
})
|
||||
|
|
|
@ -70,7 +70,7 @@ export default function ({ getService }) {
|
|||
expect(resp.body).eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: 'Not Found'
|
||||
message: 'Saved object [visualization/not an id] not found'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -99,7 +99,7 @@ export default function ({ getService }) {
|
|||
expect(resp.body).eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: 'Not Found'
|
||||
message: 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] not found'
|
||||
});
|
||||
})
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue