@lark-apaas/coding-template-nestjs-react-fullstack 0.1.78-alpha.20261203085935 → 0.1.78-beta.0
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
|
@@ -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
|
};
|