17 lines
286 B
TypeScript
Raw Normal View History

2021-11-22 16:59:38 +08:00
import log from '../util/LogUtil';
2021-06-21 16:32:10 +08:00
let f = async (ctx, next) => {
2021-11-22 16:59:38 +08:00
try {
await next();
} catch (error: any) {
if (error.status != undefined) {
ctx.status = error.status;
} else {
ctx.status = 500;
}
ctx.body = error.message;
log.error(error);
}
2021-06-21 16:32:10 +08:00
}
export default f;