From ee816f3b04037d981dfd1cd5f5ba7ab06eb70647 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Thu, 13 Jul 2023 19:25:48 +0300 Subject: [PATCH] hnng --- src/MessageBroker.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/MessageBroker.ts b/src/MessageBroker.ts index 518e605..2f443d4 100644 --- a/src/MessageBroker.ts +++ b/src/MessageBroker.ts @@ -255,7 +255,7 @@ class MessageBroker } // Subscribe to exchange, ensures messages aren't lost by binding it to a queue - async subscribe (name: string, listener: Subscriber) + async subscribe (name: string, listener: Subscriber) { if (!this.#channel) throw new Error('Channel does not exist'); @@ -270,7 +270,7 @@ class MessageBroker } - private async _subscribe (name: string, listener: Subscriber): Promise + private async _subscribe (name: string, listener: Subscriber): Promise { if (!this.#channel) return Promise.reject(new Error('Channel doesn\'t exist')); @@ -283,8 +283,10 @@ class MessageBroker { if (msg.content && msg.content.toString().startsWith('{')) await listener(JSON.parse(msg.content.toString()), msg); - else - await listener(msg.content, msg); + else + // TODO: Figure out how to do this and remaing logically consistent + throw new Error('Malformed content'); + // await listener(msg.content, msg); this.#channel?.ack(msg); }); }