- installGlobalHandler: function ( window ) {
- // We will preserve the return value of the previous handler. window.onerror works the
- // opposite way than normal event handlers (returning true will prevent the default
- // action, returning false will let the browser handle the error normally, by e.g.
- // logging to the console), so our fallback old handler needs to return false.
- var oldHandler = window.onerror || function () {
- return false;
- };
-
- /**
- * Dumb window.onerror handler which forwards the errors via mw.track.
- *
- * @param {string} errorMessage
- * @param {string} url
- * @param {number} lineNumber
- * @param {number} [columnNumber]
- * @param {Error|Mixed} [errorObject]
- * @return {boolean} True to prevent the default action
- * @fires global_error
- */
- window.onerror = function ( errorMessage, url, lineNumber, columnNumber, errorObject ) {
- mw.track( 'global.error', { errorMessage: errorMessage, url: url,
- lineNumber: lineNumber, columnNumber: columnNumber, errorObject: errorObject } );
- return oldHandler.apply( this, arguments );
- };
- }
- };
+ window.onerror = function ( errorMessage, url, lineNumber, columnNumber, errorObject ) {
+ mw.track( 'global.error', {
+ errorMessage: errorMessage,
+ url: url,
+ lineNumber: lineNumber,
+ columnNumber: columnNumber,
+ errorObject: errorObject
+ } );
+ return oldHandler.apply( this, arguments );
+ };
+ }
+};