Remove err.response from SavedObjects fetch errors

This commit is contained in:
Rudolf Meijering 2019-08-05 14:35:55 +02:00
parent 53f6800465
commit 61705ca361

View file

@ -423,11 +423,15 @@ export class SavedObjectsClient {
/**
* To ensure we don't break backwards compatibility, savedObjectsFetch keeps
* the old kfetch error format of `{res: {status: number}}` whereas `http.fetch`
* uses `{response: {status: number}}`
* uses `{response: {status: number}}`.
*
* TODO: Introduce error helper functions to make it easier to change
* the internal shape of errors.
*/
private savedObjectsFetch(path: string, { method, query, body }: HttpFetchOptions) {
return this.http.fetch(path, { method, query, body }).catch(err => {
const kfetchError = Object.assign(err, { res: err.response });
delete kfetchError.response;
return Promise.reject(kfetchError);
});
}