@lad-tech/nsc-toolkit 1.15.4 → 1.16.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/CHANGELOG.md +7 -2
- package/dist/Client.js +3 -3
- package/dist/Root.js +4 -1
- package/dist/Service.js +10 -1
- package/dist/types/Root.d.ts +1 -1
- package/dist/types/Service.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
# [1.16.0](https://github.com/lad-tech/nsc-toolkit/compare/v1.15.5...v1.16.0) (2023-09-13)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* fix test ([b54dd51](https://github.com/lad-tech/nsc-toolkit/commit/b54dd5139d34d5ae9d3138e8664434e8793d0804))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add stack in error log message ([19836db](https://github.com/lad-tech/nsc-toolkit/commit/19836db76c13fcf3742b4d10d0fe73ad6f3d33b2))
|
package/dist/Client.js
CHANGED
|
@@ -110,7 +110,7 @@ class Client extends Root_1.Root {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
async request(subject, data, { options, request, response }) {
|
|
113
|
-
var _a, _b, _c;
|
|
113
|
+
var _a, _b, _c, _d;
|
|
114
114
|
const tracer = opentelemetry.trace.getTracer('');
|
|
115
115
|
const span = tracer.startSpan(subject, undefined, this.getContext(this.baggage));
|
|
116
116
|
try {
|
|
@@ -141,9 +141,9 @@ class Client extends Root_1.Root {
|
|
|
141
141
|
? await this.makeHttpRequest(subject, message, options, timeout)
|
|
142
142
|
: await this.makeBrokerRequest(subject, message, timeout);
|
|
143
143
|
if (result.error) {
|
|
144
|
-
throw new Error(result.error.message);
|
|
144
|
+
throw new Error((_c = result.error.message) !== null && _c !== void 0 ? _c : result.error);
|
|
145
145
|
}
|
|
146
|
-
if (((
|
|
146
|
+
if (((_d = options === null || options === void 0 ? void 0 : options.runTimeValidation) === null || _d === void 0 ? void 0 : _d.response) && response) {
|
|
147
147
|
this.validate(result.payload, response);
|
|
148
148
|
}
|
|
149
149
|
if ((options === null || options === void 0 ? void 0 : options.cache) && !this.isStream(result.payload) && this.cache) {
|
package/dist/Root.js
CHANGED
|
@@ -57,9 +57,12 @@ class Root {
|
|
|
57
57
|
if (error instanceof Error) {
|
|
58
58
|
message = error.message;
|
|
59
59
|
}
|
|
60
|
-
else {
|
|
60
|
+
else if (typeof error === 'string') {
|
|
61
61
|
message = error;
|
|
62
62
|
}
|
|
63
|
+
else {
|
|
64
|
+
message = JSON.stringify(error);
|
|
65
|
+
}
|
|
63
66
|
return {
|
|
64
67
|
payload: null,
|
|
65
68
|
error: {
|
package/dist/Service.js
CHANGED
|
@@ -348,11 +348,20 @@ class Service extends Root_1.Root {
|
|
|
348
348
|
}
|
|
349
349
|
catch (error) {
|
|
350
350
|
logger.debug({ request: payload });
|
|
351
|
-
logger.error(error);
|
|
351
|
+
logger.error(this.createErrorMessageForLogger(error));
|
|
352
352
|
this.finishSpan(span, error);
|
|
353
353
|
return this.buildErrorMessage(error);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Make error object if error instance of Error object for logger
|
|
358
|
+
*/
|
|
359
|
+
createErrorMessageForLogger(error) {
|
|
360
|
+
if (error instanceof Error) {
|
|
361
|
+
return { name: error.name, message: error.message, stack: error.stack };
|
|
362
|
+
}
|
|
363
|
+
return { message: JSON.stringify(error) };
|
|
364
|
+
}
|
|
356
365
|
/**
|
|
357
366
|
* Start service. Subscribe for subject and up http server
|
|
358
367
|
*/
|
package/dist/types/Root.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class Root {
|
|
|
17
17
|
*/
|
|
18
18
|
protected getContext(baggage?: Baggage): opentelemetry.Context | undefined;
|
|
19
19
|
protected getExpired(expired?: number, ownTimeout?: number): number;
|
|
20
|
-
protected buildErrorMessage(error: string | Error, code?: number): {
|
|
20
|
+
protected buildErrorMessage(error: string | Error | Record<any, any>, code?: number): {
|
|
21
21
|
payload: null;
|
|
22
22
|
error: {
|
|
23
23
|
message: string;
|
package/dist/types/Service.d.ts
CHANGED
|
@@ -69,6 +69,10 @@ export declare class Service<E extends Emitter = Emitter> extends Root {
|
|
|
69
69
|
* Run business logic for request
|
|
70
70
|
*/
|
|
71
71
|
private handled;
|
|
72
|
+
/**
|
|
73
|
+
* Make error object if error instance of Error object for logger
|
|
74
|
+
*/
|
|
75
|
+
private createErrorMessageForLogger;
|
|
72
76
|
/**
|
|
73
77
|
* Start service. Subscribe for subject and up http server
|
|
74
78
|
*/
|