浏览代码

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 年前
父节点
当前提交
d03af36666
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9
    2
      modules/xmpp/ChatRoom.js

+ 9
- 2
modules/xmpp/ChatRoom.js 查看文件

@@ -354,9 +354,16 @@ ChatRoom.prototype.onPresence = function (pres) {
354 354
 };
355 355
 
356 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 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 369
 ChatRoom.prototype.sendMessage = function (body, nickname) {

正在加载...
取消
保存