@saihu/common 1.1.67 → 1.1.69
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-error.interceptor.d.ts","sourceRoot":"","sources":["../../src/interceptors/rpc-error.interceptor.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAK9C,qBACa,mBAAoB,YAAW,eAAe;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAE/D,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc-error.interceptor.d.ts","sourceRoot":"","sources":["../../src/interceptors/rpc-error.interceptor.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAK9C,qBACa,mBAAoB,YAAW,eAAe;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAE/D,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC;CAqCzE"}
|
|
@@ -19,43 +19,28 @@ let RpcErrorInterceptor = RpcErrorInterceptor_1 = class RpcErrorInterceptor {
|
|
|
19
19
|
this.logger = new common_1.Logger(RpcErrorInterceptor_1.name);
|
|
20
20
|
}
|
|
21
21
|
intercept(context, next) {
|
|
22
|
-
console.log('=== RpcErrorInterceptor: intercept called ===');
|
|
23
|
-
console.log('Context type:', context.getType());
|
|
24
22
|
// Only intercept RPC context
|
|
25
23
|
if (context.getType() !== 'rpc') {
|
|
26
|
-
console.log('Not RPC context, skipping');
|
|
27
24
|
return next.handle();
|
|
28
25
|
}
|
|
29
|
-
console.log('RPC context, attaching error handler');
|
|
30
26
|
return next.handle().pipe((0, operators_1.catchError)((error) => {
|
|
31
|
-
var _a
|
|
32
|
-
console.log('=== RpcErrorInterceptor: ERROR CAUGHT ===');
|
|
33
|
-
console.log('Error type:', (_a = error === null || error === void 0 ? void 0 : error.constructor) === null || _a === void 0 ? void 0 : _a.name);
|
|
34
|
-
console.log('Error instanceof BaseError:', error instanceof base_res_dto_1.BaseError);
|
|
35
|
-
console.log('Error instanceof RpcException:', error instanceof microservices_1.RpcException);
|
|
36
|
-
console.log('Error.name:', error === null || error === void 0 ? void 0 : error.name);
|
|
37
|
-
console.log('Error.code:', error === null || error === void 0 ? void 0 : error.code);
|
|
38
|
-
console.log('Error.message:', error === null || error === void 0 ? void 0 : error.message);
|
|
39
|
-
console.log('Error:', error);
|
|
27
|
+
var _a;
|
|
40
28
|
// Transform BaseError to RpcException
|
|
41
29
|
if (error instanceof base_res_dto_1.BaseError) {
|
|
42
30
|
const payload = {
|
|
43
31
|
code: error.code,
|
|
44
32
|
msg: error.message,
|
|
45
|
-
data: (
|
|
33
|
+
data: (_a = error.data) !== null && _a !== void 0 ? _a : null,
|
|
46
34
|
};
|
|
47
|
-
|
|
48
|
-
this.logger.warn(`BaseError transformed: [${payload.code}] ${payload.msg}`);
|
|
35
|
+
this.logger.warn(`BaseError: [${payload.code}] ${payload.msg}`);
|
|
49
36
|
return (0, rxjs_1.throwError)(() => new microservices_1.RpcException(payload));
|
|
50
37
|
}
|
|
51
38
|
// Already an RpcException, pass through
|
|
52
39
|
if (error instanceof microservices_1.RpcException) {
|
|
53
|
-
console.log('Already RpcException, passing through');
|
|
54
40
|
return (0, rxjs_1.throwError)(() => error);
|
|
55
41
|
}
|
|
56
42
|
// Transform other errors to generic RpcException
|
|
57
|
-
|
|
58
|
-
this.logger.error('Unhandled RPC error:', error);
|
|
43
|
+
this.logger.error('Unhandled RPC error:', (error === null || error === void 0 ? void 0 : error.message) || error);
|
|
59
44
|
return (0, rxjs_1.throwError)(() => new microservices_1.RpcException({
|
|
60
45
|
code: 500,
|
|
61
46
|
msg: (error === null || error === void 0 ? void 0 : error.message) || 'Internal server error',
|