|
|
@@ -54,6 +54,20 @@ var LibJitsiMeet = {
|
|
54
|
54
|
_gumFailedHandler: [],
|
|
55
|
55
|
init: function (options) {
|
|
56
|
56
|
Statistics.audioLevelsEnabled = !options.disableAudioLevels || true;
|
|
|
57
|
+
|
|
|
58
|
+ if (options.enableWindowOnErrorHandler) {
|
|
|
59
|
+ // if an old handler exists also fire its events
|
|
|
60
|
+ var oldOnErrorHandler = window.onerror;
|
|
|
61
|
+ window.onerror = function (message, source, lineno, colno, error) {
|
|
|
62
|
+
|
|
|
63
|
+ JitsiMeetJS.getGlobalOnErrorHandler(
|
|
|
64
|
+ message, source, lineno, colno, error);
|
|
|
65
|
+
|
|
|
66
|
+ if(oldOnErrorHandler)
|
|
|
67
|
+ oldOnErrorHandler(message, source, lineno, colno, error);
|
|
|
68
|
+ }
|
|
|
69
|
+ }
|
|
|
70
|
+
|
|
57
|
71
|
return RTC.init(options || {});
|
|
58
|
72
|
},
|
|
59
|
73
|
/**
|
|
|
@@ -136,6 +150,31 @@ var LibJitsiMeet = {
|
|
136
|
150
|
enumerateDevices: function (callback) {
|
|
137
|
151
|
RTC.enumerateDevices(callback);
|
|
138
|
152
|
},
|
|
|
153
|
+ /**
|
|
|
154
|
+ * Array of functions that will receive the unhandled errors.
|
|
|
155
|
+ */
|
|
|
156
|
+ _globalOnErrorHandler: [],
|
|
|
157
|
+ /**
|
|
|
158
|
+ * @returns function that can be used to be attached to window.onerror and
|
|
|
159
|
+ * if options.enableWindowOnErrorHandler is enabled returns
|
|
|
160
|
+ * the function used by the lib.
|
|
|
161
|
+ * (function(message, source, lineno, colno, error)).
|
|
|
162
|
+ */
|
|
|
163
|
+ getGlobalOnErrorHandler: function (message, source, lineno, colno, error) {
|
|
|
164
|
+ console.error(
|
|
|
165
|
+ 'UnhandledError: ' + message,
|
|
|
166
|
+ 'Script: ' + source,
|
|
|
167
|
+ 'Line: ' + lineno,
|
|
|
168
|
+ 'Column: ' + colno,
|
|
|
169
|
+ 'StackTrace: ', error);
|
|
|
170
|
+
|
|
|
171
|
+ JitsiMeetJS._globalOnErrorHandler.forEach(function (handler) {
|
|
|
172
|
+ handler(error);
|
|
|
173
|
+ });
|
|
|
174
|
+ if(!JitsiMeetJS._globalOnErrorHandler.length){
|
|
|
175
|
+ Statistics.sendUnhandledError(error);
|
|
|
176
|
+ }
|
|
|
177
|
+ },
|
|
139
|
178
|
|
|
140
|
179
|
/**
|
|
141
|
180
|
* Represents a hub/namespace for utility functionality which may be of
|