Use Boom.boomify instead of deprecated Boom.wrap (#14325) (#14438)

This commit is contained in:
Kim Joar Bekkelund 2017-10-13 11:42:21 +02:00 committed by GitHub
parent 390ae79ab3
commit 7adf209ff4
7 changed files with 7 additions and 11 deletions

View file

@ -98,7 +98,7 @@ function callAPI(client, endpoint, clientParams = {}, options = {}) {
return Promise.reject(err);
}
const boomError = Boom.wrap(err, err.statusCode);
const boomError = Boom.boomify(err, { statusCode: err.statusCode });
const wwwAuthHeader = get(err, 'body.error.header[WWW-Authenticate]');
boomError.output.headers['WWW-Authenticate'] = wwwAuthHeader || 'Basic realm="Authorization Required"';

View file

@ -28,7 +28,7 @@ export function exportApi(server) {
.header('Content-Type', 'application/json')
.header('Content-Length', json.length);
})
.catch(err => reply(Boom.wrap(err, 400)));
.catch(err => reply(Boom.boomify(err, { statusCode: 400 })));
}
});
}

View file

@ -23,7 +23,7 @@ export function importApi(server) {
handler: (req, reply) => {
return importDashboards(req)
.then((resp) => reply(resp))
.catch(err => reply(Boom.wrap(err, 400)));
.catch(err => reply(Boom.boomify(err, { statusCode: 400 })));
}
});
}

View file

@ -10,7 +10,7 @@ export default (server) => {
.then(reply)
.catch(err => {
if (err.isBoom && err.status === 401) return reply(err);
reply(Boom.wrap(err, 500));
reply(Boom.boomify(err, { statusCode: 500 }));
});
}
});

View file

@ -47,11 +47,7 @@ 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);
return Boom.boomify(error, { statusCode, message });
}

View file

@ -66,7 +66,7 @@ export default async (kbnServer, server, config) => {
await reply.renderStatusPage();
}
} catch (err) {
reply(Boom.wrap(err));
reply(Boom.boomify(err));
}
}
});

View file

@ -111,7 +111,7 @@ export default function ({ getService }) {
it('handles errors that are already Boom errors', () => {
const error = new Error();
error.statusCode = 401;
const boomError = Boom.wrap(error, error.statusCode);
const boomError = Boom.boomify(error, { statusCode: error.statusCode });
const converted = convertEsError(indices, boomError);