mirror of
https://github.com/strapi/strapi.git
synced 2025-09-01 21:03:02 +00:00
Merge branch 'master' into fix/5439
This commit is contained in:
commit
06ba800a1b
@ -80,9 +80,13 @@ module.exports = strapi => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log error.
|
// Log error.
|
||||||
strapi.log.error(error);
|
|
||||||
|
|
||||||
const { status, body } = formatBoomPayload(error);
|
const { status, body } = formatBoomPayload(error);
|
||||||
|
|
||||||
|
if (status >= 500) {
|
||||||
|
strapi.log.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.body = body;
|
ctx.body = body;
|
||||||
ctx.status = status;
|
ctx.status = status;
|
||||||
}
|
}
|
||||||
@ -101,13 +105,13 @@ module.exports = strapi => {
|
|||||||
// Custom function to avoid ctx.body repeat
|
// Custom function to avoid ctx.body repeat
|
||||||
createResponses() {
|
createResponses() {
|
||||||
boomMethods.forEach(method => {
|
boomMethods.forEach(method => {
|
||||||
strapi.app.response[method] = function(...rest) {
|
strapi.app.response[method] = function(msg, ...rest) {
|
||||||
const boomError = Boom[method](...rest) || {};
|
const boomError = Boom[method](msg, ...rest) || {};
|
||||||
|
|
||||||
const { status, body } = formatBoomPayload(boomError);
|
const { status, body } = formatBoomPayload(boomError);
|
||||||
|
|
||||||
// keep retro-compatibility for old error formats
|
// keep retro-compatibility for old error formats
|
||||||
body.message = body.data;
|
body.message = msg || body.data || body.message;
|
||||||
|
|
||||||
this.body = body;
|
this.body = body;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user