Authored by 陈峰

Merge branch 'hotfix/fix' into 'release/6.7.9'

修改api



See merge request !64
... ... @@ -6,31 +6,36 @@
const logger = global.yoho.logger;
const serverError = (err, req, res, next) => { // eslint-disable-line
logger.error(err);
logger.error(err);
let code = 500, msg = '服务器错误!';
return res.status(500).json({
code: 500,
message: '服务器错误!'
});
if (err.code && typeof err.code === 'number' && err.code !== 500 && err.message && !err.message.match(/_ERROR/gi)[0]) {
code = err.code;
msg = err.message;
}
return res.status(code).json({
code: code,
message: msg
});
};
const notFound = (req, res) => {
res.status(404);
if (req.xhr) {
return res.json({
code: 404,
message: '请求路径不存在'
});
}
res.status(404);
res.render('error/404', {
layout: false
if (req.xhr) {
return res.json({
code: 404,
message: '请求路径不存在'
});
}
res.render('error/404', {
layout: false
});
};
module.exports = {
notFound,
serverError
notFound,
serverError
};
... ...