Selaa lähdekoodia

Handles the errors thrown by the data channel methods

j8
hristoterezov 8 vuotta sitten
vanhempi
commit
8d162609e0
2 muutettua tiedostoa jossa 40 lisäystä ja 15 poistoa
  1. 28
    15
      conference.js
  2. 12
    0
      modules/util/helpers.js

+ 28
- 15
conference.js Näytä tiedosto

14
 
14
 
15
 import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
15
 import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
16
 
16
 
17
+import {reportError} from './modules/util/helpers';
18
+
17
 const ConnectionEvents = JitsiMeetJS.events.connection;
19
 const ConnectionEvents = JitsiMeetJS.events.connection;
18
 const ConnectionErrors = JitsiMeetJS.errors.connection;
20
 const ConnectionErrors = JitsiMeetJS.errors.connection;
19
 
21
 
1153
         ConnectionQuality.addListener(CQEvents.LOCALSTATS_UPDATED,
1155
         ConnectionQuality.addListener(CQEvents.LOCALSTATS_UPDATED,
1154
             (percent, stats) => {
1156
             (percent, stats) => {
1155
                 APP.UI.updateLocalStats(percent, stats);
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
         room.on(ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
1167
         room.on(ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
1279
         });
1285
         });
1280
 
1286
 
1281
         APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, (id) => {
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
         APP.UI.addListener(UIEvents.PINNED_ENDPOINT, (smallVideo, isPinned) => {
1295
         APP.UI.addListener(UIEvents.PINNED_ENDPOINT, (smallVideo, isPinned) => {
1286
             var smallVideoId = smallVideo.getId();
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
         APP.UI.addListener(
1313
         APP.UI.addListener(

+ 12
- 0
modules/util/helpers.js Näytä tiedosto

19
 export function reload () {
19
 export function reload () {
20
     window.location.reload();
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
+}

Loading…
Peruuta
Tallenna