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); }); }