diff options
author | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-04-06 22:53:07 +0100 |
---|---|---|
committer | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-04-06 22:53:07 +0100 |
commit | 2d0dc5aab6dbeab3105bc6bfc2ffacbcc33c6bb5 (patch) | |
tree | 0783700055016655f05ffed24cc64f7c72a66fae | |
parent | 5dc72234abc4eba771f6288bb6673e477d7fec3c (diff) | |
download | etherpad-lite-2d0dc5aab6dbeab3105bc6bfc2ffacbcc33c6bb5.zip |
Improve the Error Messages
-rw-r--r-- | node/server.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/node/server.js b/node/server.js index a44bc7e7..16d27012 100644 --- a/node/server.js +++ b/node/server.js @@ -122,21 +122,39 @@ messageHandler.setSocketIO(io); io.on('connection', function(client){ try{ messageHandler.handleConnect(client); - }catch(e){console.error(e);} + }catch(e){errorlog(e);} client.on('message', function(message){ try{ messageHandler.handleMessage(client, message); - }catch(e){console.error(e);} + }catch(e){errorlog(e);} }); client.on('disconnect', function(){ try{ messageHandler.handleDisconnect(client); - }catch(e){console.error(e);} + }catch(e){errorlog(e);} }); }); +function errorlog(e) +{ + var timeStr = new Date().toUTCString() + ": "; + + if(typeof e == "string") + { + console.error(timeStr + e); + } + else if(e.stack != null) + { + console.error(timeStr + e.stack); + } + else + { + console.error(timeStr + JSON.stringify(e)); + } +} + |