Improve error throwing for sending events

This commit is contained in:
Cooldude2606 committed 2024-05-18 18:42:53 +01:00
1 parent 0c9e91b953
commit d1fa5e67d4
3 files changed
+27 -29

No files matched your search

+6
View File
@@ -538,6 +538,9 @@ export class Link {
if (!entry) {
throw new Error(`Attempt to send unregistered Request ${request.constructor.name}`);
}
if (this.connector.src.equals(dst)) {
throw new Error(`Message would return back to sender ${dst}.`);
}
if (this.validateSent) {
entry.requestFromJSON(JSON.parse(JSON.stringify(request)));
}
@@ -572,6 +575,9 @@ export class Link {
if (!entry) {
throw new Error(`Attempt to send unregistered Event ${event.constructor.name}`);
}
if (this.connector.src.equals(dst)) {
throw new Error(`Message would return back to sender ${dst}.`);
}
if (this.validateSent) {
entry.eventFromJSON(JSON.parse(JSON.stringify(event)));
}