|
@@ -8,7 +8,7 @@ import { Context } from '@midwayjs/koa';
|
|
|
import { LoginError } from '../error/login.error';
|
|
|
import { ServiceError } from '../error/service.error';
|
|
|
import { MidwayI18nService } from '@midwayjs/i18n';
|
|
|
-
|
|
|
+import { toLower } from 'lodash';
|
|
|
interface CustomError extends Error {
|
|
|
group: string;
|
|
|
}
|
|
@@ -19,14 +19,13 @@ export class CustomErrorFilter {
|
|
|
ctx: Context;
|
|
|
@ApplicationContext()
|
|
|
applicationContext: IMidwayContainer;
|
|
|
- // @Inject()
|
|
|
- // i18n: MidwayI18nService;
|
|
|
async catch(err: CustomError, ctx: Context) {
|
|
|
// 所有的未分类错误会到这里
|
|
|
const i18n = await this.applicationContext.getAsync(MidwayI18nService);
|
|
|
const errmsg = i18n.translate(err.message, {
|
|
|
locale: this.ctx.locale,
|
|
|
- group: err.group,
|
|
|
+ // 需要全小写
|
|
|
+ group: toLower(err.group),
|
|
|
});
|
|
|
const result: any = {
|
|
|
errcode: err.message,
|