...
|
...
|
@@ -5,6 +5,7 @@ |
|
|
const headerModel = require('../models/header');
|
|
|
const logger = global.yoho.logger;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const sender = global.yoho.apmSender;
|
|
|
|
|
|
const forceNoCache = (res) => {
|
|
|
if (res && !res.finished) {
|
...
|
...
|
@@ -49,6 +50,24 @@ exports.notFound = () => { |
|
|
exports.serverError = () => {
|
|
|
return (err, req, res, next) => {
|
|
|
forceNoCache(res);
|
|
|
const uid = this.ctx.req.user.uid || 0;
|
|
|
const udid = this.ctx.req.query.udid || this.ctx.req.cookies._yasvd;
|
|
|
|
|
|
//上报服务端错误
|
|
|
sender.addMessage({
|
|
|
measurement: 'error-report',
|
|
|
tags: {
|
|
|
type: 'server',
|
|
|
reqID: req.reqID,
|
|
|
uid,
|
|
|
udid,
|
|
|
code: err.code || 500
|
|
|
},
|
|
|
fields: {
|
|
|
message: err.message,
|
|
|
stack: err.stack
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (err && err.code === 401) {
|
|
|
logger.error(`401 error info:client_type=${req.query.client_type},req.user=${JSON.stringify(req.user)},req.query=${JSON.stringify(req.query)},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
|
...
|
...
|
|