Pārlūkot izejas kodu

Catch all errors comming from command handlers to avoid detaching presence handler from strophe connection.

dev1
damencho 9 gadus atpakaļ
vecāks
revīzija
1ddc21e33e
1 mainītis faili ar 9 papildinājumiem un 2 dzēšanām
  1. 9
    2
      modules/xmpp/ChatRoom.js

+ 9
- 2
modules/xmpp/ChatRoom.js Parādīt failu

@@ -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) {

Notiek ielāde…
Atcelt
Saglabāt