chore: format

This commit is contained in:
xiaojunnuo
2026-05-31 01:41:33 +08:00
parent acd440106b
commit 4b57a0d729
557 changed files with 12530 additions and 14039 deletions
@@ -1,6 +1,6 @@
import { Provide } from '@midwayjs/core';
import { IMidwayKoaContext, IWebMiddleware, NextFunction } from '@midwayjs/koa';
import { logger } from '@certd/basic';
import { Provide } from "@midwayjs/core";
import { IMidwayKoaContext, IWebMiddleware, NextFunction } from "@midwayjs/koa";
import { logger } from "@certd/basic";
import { Result, TextException } from "@certd/lib-server";
@Provide()
@@ -9,20 +9,20 @@ export class GlobalExceptionMiddleware implements IWebMiddleware {
return async (ctx: IMidwayKoaContext, next: NextFunction) => {
const { url } = ctx;
const startTime = Date.now();
logger.info('请求开始:', url);
logger.info("请求开始:", url);
try {
await next();
logger.info('请求完成:', url, Date.now() - startTime + 'ms');
logger.info("请求完成:", url, Date.now() - startTime + "ms");
} catch (err) {
if(err instanceof TextException){
delete err.stack
if (err instanceof TextException) {
delete err.stack;
}
logger.error('请求异常:', url, Date.now() - startTime + 'ms', err);
logger.error("请求异常:", url, Date.now() - startTime + "ms", err);
ctx.status = 200;
if (err.code == null || typeof err.code !== 'number') {
if (err.code == null || typeof err.code !== "number") {
err.code = 1;
}
ctx.body = Result.error(err.code, err.message,err.data);
ctx.body = Result.error(err.code, err.message, err.data);
}
};
}