From: Timo Tijhof Date: Thu, 28 Jun 2012 12:07:10 +0000 (+0200) Subject: Fix broken console.error.call in IE9 X-Git-Tag: 1.31.0-rc.0~23210 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=605ebb52872e4ab53f64588108d258e08bb8ea01;p=lhc%2Fweb%2Fwiklou.git Fix broken console.error.call in IE9 * It turns out IE9 throws up on console.error.call ("TypeError: Object does not property method 'call'.") Which is problematic since module handlers that catch exceptions and try to log them, now still get a global uncaught exception. Luckily it only affected users of IE9 that have DevTools installed locally -and- were on a page with module that throws an exception. * Follows-up 4c80300499d783333e24331f7c5a368ecf24c3bf * Now just not logging the exception object if there is no console.error. Pretty much every console has it, and when they don't, then having the exception object is likely not going to help either. Not to confuse with mw.log, which is elaborate cross-browser fallbacks and always shows all information in the browser somehow. This is for logging errors without debug mode. Change-Id: I1bf6c6f963ca64182dd447bebc0e6751bce325ae --- diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js index 793cf225ed..f29a9bd377 100644 --- a/resources/mediawiki/mediawiki.js +++ b/resources/mediawiki/mediawiki.js @@ -637,10 +637,12 @@ var mw = ( function ( $, undefined ) { var console = window.console; if ( console && console.log ) { console.log( msg ); - // console.error triggers the proper handling of exception objects in - // consoles that support it. Fallback to passing as plain object to log(). - if ( e ) { - (console.error || console.log).call( console, e ); + // If we have an exception object, log it through .error() to trigger + // proper stacktraces in browsers that support it. There are no (known) + // browsers that don't support .error(), that do support .log() and + // have useful exception handling through .log(). + if ( e && console.error ) { + console.error( e ); } } } @@ -697,7 +699,7 @@ var mw = ( function ( $, undefined ) { } catch ( ex ) { // A user-defined operation raised an exception. Swallow to protect // our state machine! - log( 'mw.loader::handlePending> Exception thrown by job.error()', ex ); + log( 'Exception thrown by job.error()', ex ); } } }