We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd038c0 commit 4e11136Copy full SHA for 4e11136
packages/pubsub/src/index.ts
@@ -38,7 +38,23 @@ export const createTopic = <TEvent extends Event = Event>(topicName?: string): T
38
},
39
async publish(event: TEvent) {
40
for (const cb of subscribers) {
41
- await cb(event);
+ try {
42
+ await cb(event);
43
+ } catch (e) {
44
+ console.error(
45
+ `An error occurred while publishing an event (topic: ${topicName}).`,
46
+ {
47
+ topicName: topicName,
48
+ error: {
49
+ message: e.message,
50
+ code: e.code,
51
+ data: e.data,
52
+ stack: e.stack
53
+ }
54
55
+ );
56
+ throw e;
57
58
}
59
60
};
0 commit comments