@lark-apaas/coding-template-nestjs-react-fullstack 0.1.78-alpha.20261203085935 → 0.1.78-alpha.20261203104607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7333,9 +7333,6 @@
|
|
|
7333
7333
|
"x64"
|
|
7334
7334
|
],
|
|
7335
7335
|
"dev": true,
|
|
7336
|
-
"libc": [
|
|
7337
|
-
"glibc"
|
|
7338
|
-
],
|
|
7339
7336
|
"license": "Apache-2.0 AND MIT",
|
|
7340
7337
|
"optional": true,
|
|
7341
7338
|
"os": [
|
|
@@ -7353,9 +7350,6 @@
|
|
|
7353
7350
|
"x64"
|
|
7354
7351
|
],
|
|
7355
7352
|
"dev": true,
|
|
7356
|
-
"libc": [
|
|
7357
|
-
"musl"
|
|
7358
|
-
],
|
|
7359
7353
|
"license": "Apache-2.0 AND MIT",
|
|
7360
7354
|
"optional": true,
|
|
7361
7355
|
"os": [
|
|
@@ -62,12 +62,17 @@ export class GlobalExceptionFilter implements ExceptionFilter {
|
|
|
62
62
|
} else {
|
|
63
63
|
// 未知异常
|
|
64
64
|
httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
65
|
+
const cause = (exception as Error).cause;
|
|
65
66
|
errorResponse = {
|
|
66
67
|
error: {
|
|
67
68
|
code: ResponseCode.INTERNAL_ERROR,
|
|
68
69
|
message: '服务器内部错误',
|
|
69
70
|
stack: (exception as Error).stack,
|
|
70
|
-
|
|
71
|
+
// 开发态显式保留不可枚举的 message;发布态保持原有序列化,避免暴露内部响应正文。
|
|
72
|
+
cause:
|
|
73
|
+
cause instanceof Error && process.env.NODE_ENV === 'development'
|
|
74
|
+
? { ...cause, message: cause.message }
|
|
75
|
+
: cause,
|
|
71
76
|
timestamp: Date.now(),
|
|
72
77
|
},
|
|
73
78
|
};
|
|
@@ -12,8 +12,8 @@ export interface ApiErrorResponse {
|
|
|
12
12
|
fieldErrors?: Record<string, string[]>;
|
|
13
13
|
/** 调用栈(仅开发环境) */
|
|
14
14
|
stack?: string;
|
|
15
|
-
/**
|
|
16
|
-
cause?:
|
|
15
|
+
/** 错误原因,可为文本或包含 message 的结构化错误 */
|
|
16
|
+
cause?: unknown;
|
|
17
17
|
/** 错误发生时间 */
|
|
18
18
|
timestamp?: number;
|
|
19
19
|
};
|