Quellcode durchsuchen

Handles the errors thrown by the data channel methods

j8
hristoterezov vor 8 Jahren
Ursprung
Commit
8d162609e0
2 geänderte Dateien mit 40 neuen und 15 gelöschten Zeilen
  1. 28
    15
      conference.js
  2. 12
    0
      modules/util/helpers.js

+ 28
- 15
conference.js Datei anzeigen

@@ -14,6 +14,8 @@ import UIEvents from './service/UI/UIEvents';
14 14
 
15 15
 import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
16 16
 
17
+import {reportError} from './modules/util/helpers';
18
+
17 19
 const ConnectionEvents = JitsiMeetJS.events.connection;
18 20
 const ConnectionErrors = JitsiMeetJS.errors.connection;
19 21
 
@@ -1153,9 +1155,13 @@ export default {
1153 1155
         ConnectionQuality.addListener(CQEvents.LOCALSTATS_UPDATED,
1154 1156
             (percent, stats) => {
1155 1157
                 APP.UI.updateLocalStats(percent, stats);
1156
-                room.broadcastEndpointMessage({
1157
-                    type: this.commands.defaults.CONNECTION_QUALITY,
1158
-                    values: stats });
1158
+                try {
1159
+                    room.broadcastEndpointMessage({
1160
+                        type: this.commands.defaults.CONNECTION_QUALITY,
1161
+                        values: stats });
1162
+                } catch (e) {
1163
+                    reportError(e);
1164
+                }
1159 1165
             });
1160 1166
 
1161 1167
         room.on(ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
@@ -1279,22 +1285,29 @@ export default {
1279 1285
         });
1280 1286
 
1281 1287
         APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, (id) => {
1282
-            room.selectParticipant(id);
1288
+            try {
1289
+                room.selectParticipant(id);
1290
+            } catch (e) {
1291
+                reportError(e);
1292
+            }
1283 1293
         });
1284 1294
 
1285 1295
         APP.UI.addListener(UIEvents.PINNED_ENDPOINT, (smallVideo, isPinned) => {
1286 1296
             var smallVideoId = smallVideo.getId();
1287
-
1288
-            if (smallVideo.getVideoType() === VIDEO_CONTAINER_TYPE
1289
-                && !APP.conference.isLocalId(smallVideoId))
1290
-                if (isPinned)
1291
-                    room.pinParticipant(smallVideoId);
1292
-                // When the library starts supporting multiple pins we would
1293
-                // pass the isPinned parameter together with the identifier,
1294
-                // but currently we send null to indicate that we unpin the
1295
-                // last pinned.
1296
-                else
1297
-                    room.pinParticipant(null);
1297
+            try {
1298
+                if (smallVideo.getVideoType() === VIDEO_CONTAINER_TYPE
1299
+                    && !APP.conference.isLocalId(smallVideoId))
1300
+                    if (isPinned)
1301
+                            room.pinParticipant(smallVideoId);
1302
+                    // When the library starts supporting multiple pins we would
1303
+                    // pass the isPinned parameter together with the identifier,
1304
+                    // but currently we send null to indicate that we unpin the
1305
+                    // last pinned.
1306
+                    else
1307
+                        room.pinParticipant(null);
1308
+            } catch (e) {
1309
+                reportError(e);
1310
+            }
1298 1311
         });
1299 1312
 
1300 1313
         APP.UI.addListener(

+ 12
- 0
modules/util/helpers.js Datei anzeigen

@@ -19,3 +19,15 @@ export function createDeferred () {
19 19
 export function reload () {
20 20
     window.location.reload();
21 21
 }
22
+
23
+/**
24
+ * Prints the error and reports it to the global error handler.
25
+ * @param e {Error} the error
26
+ * @param msg {string} [optional] the message printed in addition to the error
27
+ */
28
+export function reportError (e, msg = "") {
29
+    console.error(msg, e);
30
+    if(window.onerror)
31
+        window.onerror(msg, null, null,
32
+            null, e);
33
+}

Laden…
Abbrechen
Speichern