From 15c6dc280c35fd8803c0dfe483fc282f6955bbdc Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 10 Dec 2011 17:52:40 +0000 Subject: [PATCH] websocketMessage JSON parsing error catching --- server/app.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/app.js b/server/app.js index 26839f7..7f544a5 100644 --- a/server/app.js +++ b/server/app.js @@ -996,11 +996,16 @@ this.IRCConnection = function (websocket, nick, host, port, ssl, password, callb this.websocketMessage = function (websocket, msg, callback) { var args, obj, channels, keys; - try { + //try { if ((callback) && (typeof (callback) !== 'function')) { callback = null; } - msg.data = JSON.parse(msg.data); + try { + msg.data = JSON.parse(msg.data); + } catch (e) { + kiwi.log('[app.websocketMessage] JSON parsing error ' + msg.data); + return; + } args = msg.data.args; switch (msg.data.method) { case 'privmsg': @@ -1091,9 +1096,9 @@ this.websocketMessage = function (websocket, msg, callback) { break; default: } - } catch (e) { - kiwi.log("Caught error: " + e); - } + //} catch (e) { + // kiwi.log("Caught error (app.websocketMessage): " + e); + //} }; -- 2.25.1