From 0314829353afc8afe134dff1f652cb2b45291ffc Mon Sep 17 00:00:00 2001 From: Lamp Date: Mon, 26 Nov 2018 14:17:13 -0800 Subject: [PATCH] better error handling --- src/lib/Client.js | 4 +--- src/mppbridger/index.js | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib/Client.js b/src/lib/Client.js index d57bb5a..0f0fa1d 100755 --- a/src/lib/Client.js +++ b/src/lib/Client.js @@ -111,10 +111,8 @@ Client.prototype.connect = function() { setTimeout(self.connect.bind(self), ms); }); this.ws.addEventListener("error", function(error) { - console.error(error.toString()); + self.emit("error", error); self.ws.emit("close"); - //self.emit('disconnect', error.toString()); //TODO - //if (error.toString() == "Error: unexpected server response (403)") process.exit(); }); this.ws.addEventListener("open", function(evt) { self.connectionTime = Date.now(); diff --git a/src/mppbridger/index.js b/src/mppbridger/index.js index 5f9f6f4..fe1c41c 100755 --- a/src/mppbridger/index.js +++ b/src/mppbridger/index.js @@ -43,6 +43,7 @@ global.createMPPbridge = function createMPPbridge(room, DiscordChannelID, site = site == "CMPC" ? new Client("ws://charsy.meowbin.com:16562") : undefined; if (!gClient) return console.error(`Invalid site ${site}`); + gClient.on("error", error => console.error(`[${site}][${room}]`, error.message)) gClient.setChannel(/*(site == "MPP" && room == "lobby") ? "lolwutsecretlobbybackdoor" : */room); gClient.start();