import { Catch } from '@midwayjs/core'; import { Context } from '@midwayjs/koa'; import { ServiceError } from '../error/service.error'; @Catch(ServiceError) export class CustomErrorFilter { async catch(err: Error, ctx: Context) { // 所有的未分类错误会到这里 return { errcode: err['code'], errmsg: err.message, details: err.stack, }; } }