From: Trevor Parscal Date: Tue, 29 Mar 2011 22:08:57 +0000 (+0000) Subject: Swtiched to using console.log if present so that when errors occur inside of modules... X-Git-Tag: 1.31.0-rc.0~31138 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/Category:Foo?a=commitdiff_plain;h=f8c7a87b621ed74d671f9ffa2852347d4efe08a6;p=lhc%2Fweb%2Fwiklou.git Swtiched to using console.log if present so that when errors occur inside of modules they are shown, even if you aren't in debug mode. This helps avoid the common pitfall of forgetting to export a symbol to the global space, because in debug mode everything is exported to the global space whereas in production mode it's wrapped in a closure. --- diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js index fb68e3be87..21e854f19e 100644 --- a/resources/mediawiki/mediawiki.js +++ b/resources/mediawiki/mediawiki.js @@ -718,8 +718,12 @@ window.mediaWiki = new ( function( $ ) { } } } catch ( e ) { - mw.log( _fn + 'Exception thrown by ' + module + ': ' + e.message ); - mw.log( e ); + // This needs to NOT use mw.log because these errors are common in production mode + // and not in debug mode, such as when a symbol that should be global isn't exported + if ( console && typeof console.log === 'function' ) { + console.log( _fn + 'Exception thrown by ' + module + ': ' + e.message ); + console.log( e ); + } registry[module].state = 'error'; // Run error callbacks of jobs affected by this condition for ( var j = 0; j < jobs.length; j++ ) {