@saihu/common 1.1.63 → 1.1.64
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":"base-error-rpc.filter.d.ts","sourceRoot":"","sources":["../../src/filters/base-error-rpc.filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAgB,MAAM,uBAAuB,CAAC;AAG7E,qBACa,kBAAmB,SAAQ,sBAAsB;IAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAE9D,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"base-error-rpc.filter.d.ts","sourceRoot":"","sources":["../../src/filters/base-error-rpc.filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAgB,MAAM,uBAAuB,CAAC;AAG7E,qBACa,kBAAmB,SAAQ,sBAAsB;IAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAE9D,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa;CAuD1C"}
|
|
@@ -18,34 +18,41 @@ let BaseErrorRpcFilter = BaseErrorRpcFilter_1 = class BaseErrorRpcFilter extends
|
|
|
18
18
|
this.logger = new common_1.Logger(BaseErrorRpcFilter_1.name);
|
|
19
19
|
}
|
|
20
20
|
catch(exception, host) {
|
|
21
|
-
var _a;
|
|
21
|
+
var _a, _b;
|
|
22
|
+
console.log('=== BaseErrorRpcFilter TRIGGERED ===');
|
|
23
|
+
console.log('Exception type:', (_a = exception === null || exception === void 0 ? void 0 : exception.constructor) === null || _a === void 0 ? void 0 : _a.name);
|
|
24
|
+
console.log('Exception name:', exception === null || exception === void 0 ? void 0 : exception.name);
|
|
25
|
+
console.log('Exception instanceof BaseError:', exception instanceof base_res_dto_1.BaseError);
|
|
26
|
+
console.log('Exception instanceof RpcException:', exception instanceof microservices_1.RpcException);
|
|
27
|
+
console.log('Exception keys:', Object.keys(exception || {}));
|
|
28
|
+
console.log('Exception:', exception);
|
|
29
|
+
console.log('Host type:', host.getType());
|
|
30
|
+
console.log('=====================================');
|
|
22
31
|
// Skip if already an RpcException
|
|
23
32
|
if (exception instanceof microservices_1.RpcException) {
|
|
33
|
+
console.log('Already RpcException, passing through');
|
|
24
34
|
return super.catch(exception, host);
|
|
25
35
|
}
|
|
26
36
|
// Check if it's a BaseError using duck-typing
|
|
27
|
-
// This is more reliable than instanceof for serialized errors
|
|
28
37
|
const isBaseErrorLike = exception &&
|
|
29
38
|
typeof exception === 'object' &&
|
|
30
39
|
exception.name === 'BaseError' &&
|
|
31
40
|
typeof exception.code === 'number' &&
|
|
32
41
|
typeof exception.message === 'string';
|
|
42
|
+
console.log('isBaseErrorLike:', isBaseErrorLike);
|
|
33
43
|
if (isBaseErrorLike || exception instanceof base_res_dto_1.BaseError) {
|
|
34
44
|
const payload = {
|
|
35
45
|
code: exception.code,
|
|
36
46
|
msg: exception.message,
|
|
37
|
-
data: (
|
|
47
|
+
data: (_b = exception.data) !== null && _b !== void 0 ? _b : null,
|
|
38
48
|
};
|
|
49
|
+
console.log('Transforming to RpcException with payload:', payload);
|
|
39
50
|
this.logger.log(`BaseError caught: [${payload.code}] ${payload.msg}`);
|
|
40
51
|
return super.catch(new microservices_1.RpcException(payload), host);
|
|
41
52
|
}
|
|
42
53
|
// Handle all other errors
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
message: exception === null || exception === void 0 ? void 0 : exception.message,
|
|
46
|
-
code: exception === null || exception === void 0 ? void 0 : exception.code,
|
|
47
|
-
stack: exception === null || exception === void 0 ? void 0 : exception.stack,
|
|
48
|
-
});
|
|
54
|
+
console.log('Unhandled error, wrapping as 500');
|
|
55
|
+
this.logger.error('Unhandled RPC error:', exception);
|
|
49
56
|
const payload = {
|
|
50
57
|
code: 500,
|
|
51
58
|
msg: (exception === null || exception === void 0 ? void 0 : exception.message) || 'Internal server error',
|