Browse files

Catch all errors - we shouldn't let clients crash the server

  • Loading branch information...
1 parent 016bba7 commit c87e8510b1eae8cd4f120d869fae994f09072236 @maccman maccman committed Dec 17, 2010
Showing with 20 additions and 16 deletions.
  1. +20 −16 lib/juggernaut/connection.js
View
36 lib/juggernaut/connection.js
@@ -18,23 +18,27 @@ Connection.include({
try {
var message = Message.fromJSON(data);
- } catch(e) { return; }
- switch (message.type){
- case "subscribe":
- this.client.subscribe(message.getChannel());
- break;
- case "unsubscribe":
- this.client.unsubscribe(message.getChannel());
- break;
- case "meta":
- this.client.setMeta(message.data);
- break;
- case "event":
- this.client.event(message.data);
- break;
- default:
- throw "Unknown type"
+ switch (message.type){
+ case "subscribe":
+ this.client.subscribe(message.getChannel());
+ break;
+ case "unsubscribe":
+ this.client.unsubscribe(message.getChannel());
+ break;
+ case "meta":
+ this.client.setMeta(message.data);
+ break;
+ case "event":
+ this.client.event(message.data);
+ break;
+ default:
+ throw "Unknown type"
+ }
+ } catch(e) {
+ sys.error("Error!");
+ sys.error(e);
+ return;
}
},

0 comments on commit c87e851

Please sign in to comment.