|
@@ -1,11 +1,10 @@
|
|
|
'use strict';
|
|
|
const _ = require('lodash');
|
|
|
-module.exports = options => {
|
|
|
+module.exports = (options) => {
|
|
|
return async function errorEmail(ctx, next) {
|
|
|
console.log('line 5 in function:');
|
|
|
try {
|
|
|
await next();
|
|
|
-
|
|
|
} catch (e) {
|
|
|
let errcode = -1,
|
|
|
errmsg = '服务发生错误',
|
|
@@ -21,7 +20,10 @@ module.exports = options => {
|
|
|
emailData.errmsg = e.stack;
|
|
|
}
|
|
|
emailData.errcode = errcode;
|
|
|
- ctx.service.util.email.errorEmail(emailData);
|
|
|
+ // 未定义的错误需要发邮件,定义的错误不需要
|
|
|
+ if (!_.isNumber(e.errcode)) {
|
|
|
+ ctx.service.util.email.errorEmail(emailData);
|
|
|
+ }
|
|
|
ctx.fail(errcode, errmsg, details);
|
|
|
}
|
|
|
};
|