style: 统一全仓代码格式
This commit is contained in:
1 parent
d811478d0f
commit
8033cabff9
30 files changed
+1183
-187
No files matched your search
+10
-6
@@ -31,18 +31,22 @@ export class ApiExceptionFilter implements ExceptionFilter {
|
||||
const request = context.getRequest<FastifyRequest>();
|
||||
const status = exception instanceof HttpException ? exception.getStatus() : 500;
|
||||
if (!(exception instanceof HttpException)) console.error("api unhandled error", exception);
|
||||
const detail = exception instanceof HttpException
|
||||
? exception.getResponse()
|
||||
: process.env.NODE_ENV === "development" && exception instanceof Error
|
||||
? exception.message
|
||||
: "服务器内部错误";
|
||||
const detail =
|
||||
exception instanceof HttpException
|
||||
? exception.getResponse()
|
||||
: process.env.NODE_ENV === "development" && exception instanceof Error
|
||||
? exception.message
|
||||
: "服务器内部错误";
|
||||
response.status(status).send({
|
||||
data: null,
|
||||
error: {
|
||||
code: `HTTP_${status}`,
|
||||
message: typeof detail === "string" ? detail : "请求失败",
|
||||
},
|
||||
requestId: (request as FastifyRequest & { requestId?: string }).requestId ?? request.headers["x-request-id"] ?? null,
|
||||
requestId:
|
||||
(request as FastifyRequest & { requestId?: string }).requestId ??
|
||||
request.headers["x-request-id"] ??
|
||||
null,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user