Browse Source

Merge pull request #52 from damencho/catch-all-from-command-handlers

Catch all errors coming from command handlers to avoid detaching pre…
dev1
hristoterezov 9 years ago
parent
commit
d03af36666
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      modules/xmpp/ChatRoom.js

+ 9
- 2
modules/xmpp/ChatRoom.js View File

354
 };
354
 };
355
 
355
 
356
 ChatRoom.prototype.processNode = function (node, from) {
356
 ChatRoom.prototype.processNode = function (node, from) {
357
-    if(this.presHandlers[node.tagName])
358
-        this.presHandlers[node.tagName](
357
+    // make sure we catch all errors coming from any handler
358
+    // otherwise we can remove the presence handler from strophe
359
+    try {
360
+        if(this.presHandlers[node.tagName])
361
+            this.presHandlers[node.tagName](
359
                 node, Strophe.getResourceFromJid(from), from);
362
                 node, Strophe.getResourceFromJid(from), from);
363
+    } catch (e) {
364
+        logger.error('Error processing:' + node.tagName
365
+            + ' node.', e);
366
+    }
360
 };
367
 };
361
 
368
 
362
 ChatRoom.prototype.sendMessage = function (body, nickname) {
369
 ChatRoom.prototype.sendMessage = function (body, nickname) {

Loading…
Cancel
Save