diff --git a/conference.js b/conference.js index 0b21d378f..7ba63a69f 100644 --- a/conference.js +++ b/conference.js @@ -14,6 +14,8 @@ import UIEvents from './service/UI/UIEvents'; import mediaDeviceHelper from './modules/devices/mediaDeviceHelper'; +import {reportError} from './modules/util/helpers'; + const ConnectionEvents = JitsiMeetJS.events.connection; const ConnectionErrors = JitsiMeetJS.errors.connection; @@ -1153,9 +1155,13 @@ export default { ConnectionQuality.addListener(CQEvents.LOCALSTATS_UPDATED, (percent, stats) => { APP.UI.updateLocalStats(percent, stats); - room.broadcastEndpointMessage({ - type: this.commands.defaults.CONNECTION_QUALITY, - values: stats }); + try { + room.broadcastEndpointMessage({ + type: this.commands.defaults.CONNECTION_QUALITY, + values: stats }); + } catch (e) { + reportError(e); + } }); room.on(ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED, @@ -1279,22 +1285,29 @@ export default { }); APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, (id) => { - room.selectParticipant(id); + try { + room.selectParticipant(id); + } catch (e) { + reportError(e); + } }); APP.UI.addListener(UIEvents.PINNED_ENDPOINT, (smallVideo, isPinned) => { var smallVideoId = smallVideo.getId(); - - if (smallVideo.getVideoType() === VIDEO_CONTAINER_TYPE - && !APP.conference.isLocalId(smallVideoId)) - if (isPinned) - room.pinParticipant(smallVideoId); - // When the library starts supporting multiple pins we would - // pass the isPinned parameter together with the identifier, - // but currently we send null to indicate that we unpin the - // last pinned. - else - room.pinParticipant(null); + try { + if (smallVideo.getVideoType() === VIDEO_CONTAINER_TYPE + && !APP.conference.isLocalId(smallVideoId)) + if (isPinned) + room.pinParticipant(smallVideoId); + // When the library starts supporting multiple pins we would + // pass the isPinned parameter together with the identifier, + // but currently we send null to indicate that we unpin the + // last pinned. + else + room.pinParticipant(null); + } catch (e) { + reportError(e); + } }); APP.UI.addListener( diff --git a/modules/util/helpers.js b/modules/util/helpers.js index 120ba7720..9d74d1ccc 100644 --- a/modules/util/helpers.js +++ b/modules/util/helpers.js @@ -19,3 +19,15 @@ export function createDeferred () { export function reload () { window.location.reload(); } + +/** + * Prints the error and reports it to the global error handler. + * @param e {Error} the error + * @param msg {string} [optional] the message printed in addition to the error + */ +export function reportError (e, msg = "") { + console.error(msg, e); + if(window.onerror) + window.onerror(msg, null, null, + null, e); +}