From f8c7a87b621ed74d671f9ffa2852347d4efe08a6 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Tue, 29 Mar 2011 22:08:57 +0000 Subject: [PATCH] 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. --- resources/mediawiki/mediawiki.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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++ ) { -- 2.20.1