default.filter.ts 287 B

12345678910111213
  1. import { Catch } from '@midwayjs/core';
  2. import { Context } from '@midwayjs/koa';
  3. @Catch()
  4. export class DefaultErrorFilter {
  5. async catch(err: Error, ctx: Context) {
  6. // 所有的未分类错误会到这里
  7. return {
  8. success: false,
  9. message: err.message,
  10. };
  11. }
  12. }