@rayondigital/nest-dapr 0.9.61 → 0.9.63
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.
|
@@ -14,6 +14,7 @@ const common_1 = require("@nestjs/common");
|
|
|
14
14
|
const dapr_context_service_1 = require("../dapr-context-service");
|
|
15
15
|
const actor_runtime_service_1 = require("./actor-runtime.service");
|
|
16
16
|
const client_cache_1 = require("./client-cache");
|
|
17
|
+
const serializable_error_1 = require("./serializable-error");
|
|
17
18
|
class ActorProxyBuilder {
|
|
18
19
|
constructor(moduleRef, actorTypeClass, ...args) {
|
|
19
20
|
this.moduleRef = moduleRef;
|
|
@@ -75,7 +76,11 @@ class ActorProxyBuilder {
|
|
|
75
76
|
const correlationId = this.daprContextService.getCorrelationId(true);
|
|
76
77
|
const traceId = this.daprContextService.getTraceId(true);
|
|
77
78
|
const body = yield this.prepareBody(this.daprContextService, args, originalBody);
|
|
78
|
-
|
|
79
|
+
const result = yield this.actorClient.actor.invoke(actorTypeClassName, actorId, methodName, body, correlationId, traceId);
|
|
80
|
+
if (serializable_error_1.SerializableError.isSerializableError(result)) {
|
|
81
|
+
throw serializable_error_1.SerializableError.fromJSON(result);
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
86
|
prepareBody(daprContextService, args, body) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export declare class SerializableError extends Error {
|
|
2
2
|
statusCode: number;
|
|
3
|
+
$type: string;
|
|
3
4
|
constructor(message: string, statusCode?: number);
|
|
4
5
|
toJSON(): {
|
|
5
6
|
name: string;
|
|
6
7
|
message: string;
|
|
7
8
|
statusCode: number;
|
|
8
9
|
};
|
|
10
|
+
static fromJSON(json: any): SerializableError;
|
|
11
|
+
static isSerializableError(error: any): error is SerializableError;
|
|
9
12
|
}
|
|
@@ -5,6 +5,7 @@ class SerializableError extends Error {
|
|
|
5
5
|
constructor(message, statusCode = 400) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.statusCode = statusCode;
|
|
8
|
+
this.$type = 'SerializableError';
|
|
8
9
|
}
|
|
9
10
|
toJSON() {
|
|
10
11
|
return {
|
|
@@ -13,5 +14,14 @@ class SerializableError extends Error {
|
|
|
13
14
|
statusCode: this.statusCode,
|
|
14
15
|
};
|
|
15
16
|
}
|
|
17
|
+
static fromJSON(json) {
|
|
18
|
+
return new SerializableError(json.message, json.statusCode);
|
|
19
|
+
}
|
|
20
|
+
static isSerializableError(error) {
|
|
21
|
+
if (error instanceof SerializableError) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return error && error.$type === 'SerializableError';
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
exports.SerializableError = SerializableError;
|
|
@@ -15,6 +15,9 @@ const nestjs_cls_1 = require("nestjs-cls");
|
|
|
15
15
|
const dapr_context_service_1 = require("../dapr-context-service");
|
|
16
16
|
function withTracedContext(contextService, operationName, operation, spanKind = api_1.SpanKind.INTERNAL, spanAttributes = undefined, tracerName = 'nest-dapr') {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (!api_1.trace || !api_1.context) {
|
|
19
|
+
return yield operation();
|
|
20
|
+
}
|
|
18
21
|
const tracer = api_1.trace.getTracer(tracerName);
|
|
19
22
|
const activeContext = api_1.context.active();
|
|
20
23
|
if (!activeContext) {
|
package/package.json
CHANGED