@yolo-croket-dev/core 1.10.0-jun.1 → 1.10.0-jun.2
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.
|
@@ -39,6 +39,26 @@ const CroketExceptions = __importStar(require("@yolo-croket-dev/core/exceptions"
|
|
|
39
39
|
*/
|
|
40
40
|
const getCroketExceptionClasses = () => Object.values(CroketExceptions).filter((value) => typeof value === 'function' && value.prototype && value.prototype.constructor === value);
|
|
41
41
|
const croketExceptionClasses = getCroketExceptionClasses();
|
|
42
|
+
const GRPC_DEBUG_ERROR_METADATA_KEY = 'debug-error';
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
45
|
+
}
|
|
46
|
+
function getStringProperty(value, key) {
|
|
47
|
+
if (!isRecord(value)) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const propertyValue = value[key];
|
|
51
|
+
return typeof propertyValue === 'string' ? propertyValue : undefined;
|
|
52
|
+
}
|
|
53
|
+
function buildDebugErrorMetadata(exception) {
|
|
54
|
+
var _a;
|
|
55
|
+
return {
|
|
56
|
+
type: ((_a = exception === null || exception === void 0 ? void 0 : exception.constructor) === null || _a === void 0 ? void 0 : _a.name) || 'Error',
|
|
57
|
+
name: getStringProperty(exception, 'name'),
|
|
58
|
+
message: getStringProperty(exception, 'message'),
|
|
59
|
+
kind: getStringProperty(exception, 'kind'),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
42
62
|
let GrpcExceptionFilter = class GrpcExceptionFilter extends microservices_1.BaseRpcExceptionFilter {
|
|
43
63
|
constructor() {
|
|
44
64
|
super(...arguments);
|
|
@@ -88,6 +108,7 @@ let GrpcExceptionFilter = class GrpcExceptionFilter extends microservices_1.Base
|
|
|
88
108
|
else {
|
|
89
109
|
errorMessage = (exception === null || exception === void 0 ? void 0 : exception.message) || 'Internal Server Error';
|
|
90
110
|
grpcStatus = grpc_js_1.status.INTERNAL;
|
|
111
|
+
metadata.set(GRPC_DEBUG_ERROR_METADATA_KEY, Buffer.from(JSON.stringify(buildDebugErrorMetadata(exception))).toString('base64'));
|
|
91
112
|
}
|
|
92
113
|
// BaseRpcExceptionFilter의 catch 메서드를 사용하여 metadata를 포함한 RpcException 생성
|
|
93
114
|
const rpcException = new microservices_1.RpcException({
|
|
@@ -37,9 +37,9 @@ exports.LoggingServiceInterceptor = void 0;
|
|
|
37
37
|
/* eslint-disable no-param-reassign */
|
|
38
38
|
const common_1 = require("@nestjs/common");
|
|
39
39
|
const msa_logger_1 = __importStar(require("@yolo-croket-dev/msa-logger"));
|
|
40
|
-
const grpc_param_metadata_function_1 = require("@yolo-croket-dev/core/functions/grpc-param-metadata.function");
|
|
41
40
|
const operators_1 = require("rxjs/operators");
|
|
42
41
|
const dd_trace_1 = __importDefault(require("dd-trace"));
|
|
42
|
+
const grpc_param_metadata_function_1 = require("../functions/grpc-param-metadata.function");
|
|
43
43
|
const { SERVER_NAME } = process.env;
|
|
44
44
|
const msaLogger = new msa_logger_1.default(msa_logger_1.ServerTypeEnum.SERVICE);
|
|
45
45
|
const MAX_CUT_LENGTH = 500;
|