@saihu/common 1.1.66 → 1.1.68
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"}
|
|
@@ -24,19 +24,15 @@ let RpcErrorInterceptor = RpcErrorInterceptor_1 = class RpcErrorInterceptor {
|
|
|
24
24
|
return next.handle();
|
|
25
25
|
}
|
|
26
26
|
return next.handle().pipe((0, operators_1.catchError)((error) => {
|
|
27
|
-
var _a
|
|
28
|
-
this.logger.debug('RPC error caught by interceptor:', {
|
|
29
|
-
type: (_a = error === null || error === void 0 ? void 0 : error.constructor) === null || _a === void 0 ? void 0 : _a.name,
|
|
30
|
-
message: error === null || error === void 0 ? void 0 : error.message,
|
|
31
|
-
});
|
|
27
|
+
var _a;
|
|
32
28
|
// Transform BaseError to RpcException
|
|
33
29
|
if (error instanceof base_res_dto_1.BaseError) {
|
|
34
30
|
const payload = {
|
|
35
31
|
code: error.code,
|
|
36
32
|
msg: error.message,
|
|
37
|
-
data: (
|
|
33
|
+
data: (_a = error.data) !== null && _a !== void 0 ? _a : null,
|
|
38
34
|
};
|
|
39
|
-
this.logger.warn(`BaseError
|
|
35
|
+
this.logger.warn(`BaseError: [${payload.code}] ${payload.msg}`);
|
|
40
36
|
return (0, rxjs_1.throwError)(() => new microservices_1.RpcException(payload));
|
|
41
37
|
}
|
|
42
38
|
// Already an RpcException, pass through
|
|
@@ -44,7 +40,7 @@ let RpcErrorInterceptor = RpcErrorInterceptor_1 = class RpcErrorInterceptor {
|
|
|
44
40
|
return (0, rxjs_1.throwError)(() => error);
|
|
45
41
|
}
|
|
46
42
|
// Transform other errors to generic RpcException
|
|
47
|
-
this.logger.error('Unhandled RPC error:', error);
|
|
43
|
+
this.logger.error('Unhandled RPC error:', (error === null || error === void 0 ? void 0 : error.message) || error);
|
|
48
44
|
return (0, rxjs_1.throwError)(() => new microservices_1.RpcException({
|
|
49
45
|
code: 500,
|
|
50
46
|
msg: (error === null || error === void 0 ? void 0 : error.message) || 'Internal server error',
|