Merge branch 'master' into fix/5439

This commit is contained in:
cyril lopez 2020-03-06 09:59:28 +01:00 committed by GitHub
commit 06ba800a1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,9 +80,13 @@ module.exports = strapi => {
}
// Log error.
strapi.log.error(error);
const { status, body } = formatBoomPayload(error);
if (status >= 500) {
strapi.log.error(error);
}
ctx.body = body;
ctx.status = status;
}
@ -101,13 +105,13 @@ module.exports = strapi => {
// Custom function to avoid ctx.body repeat
createResponses() {
boomMethods.forEach(method => {
strapi.app.response[method] = function(...rest) {
const boomError = Boom[method](...rest) || {};
strapi.app.response[method] = function(msg, ...rest) {
const boomError = Boom[method](msg, ...rest) || {};
const { status, body } = formatBoomPayload(boomError);
// keep retro-compatibility for old error formats
body.message = body.data;
body.message = msg || body.data || body.message;
this.body = body;
this.status = status;