|
|
@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const logger = require('../../utils/logger.util');
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = async (ctx, next) => {
|
|
|
|
module.exports = async (ctx, next) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const data = await next();
|
|
|
|
const data = await next();
|
|
|
@ -10,10 +13,10 @@ module.exports = async (ctx, next) => {
|
|
|
|
ctx.status = 200; // Set status to 200 if not already set
|
|
|
|
ctx.status = 200; // Set status to 200 if not already set
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
console.log('Error handler:', err);
|
|
|
|
logger.error('Error handler:', err);
|
|
|
|
// ctx.status = 200; // err.status || 500;
|
|
|
|
// ctx.status = 200; // err.status || 500;
|
|
|
|
ctx.body = {
|
|
|
|
ctx.body = {
|
|
|
|
errcode: 1,
|
|
|
|
errcode: err.status || 500,
|
|
|
|
errmsg: err.message || 'Internal server error',
|
|
|
|
errmsg: err.message || 'Internal server error',
|
|
|
|
statuscode: err.status,
|
|
|
|
statuscode: err.status,
|
|
|
|
result: null,
|
|
|
|
result: null,
|
|
|
|