From: Darren Date: Sat, 10 Dec 2011 17:52:40 +0000 (+0000) Subject: websocketMessage JSON parsing error catching X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=15c6dc280c35fd8803c0dfe483fc282f6955bbdc;p=KiwiIRC.git websocketMessage JSON parsing error catching --- 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); + //} };