jenkins-bot has submitted this change and it was merged.

Change subject: Fully log exceptions within ResourceLoader (including traces)
......................................................................


Fully log exceptions within ResourceLoader (including traces)

Change-Id: Icb479c76cd855244429fe65b29667783dcca8f53
---
M includes/Exception.php
M includes/resourceloader/ResourceLoader.php
2 files changed, 23 insertions(+), 9 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Exception.php b/includes/Exception.php
index dc1208a..e1bfb2d 100644
--- a/includes/Exception.php
+++ b/includes/Exception.php
@@ -247,16 +247,9 @@
         * It will be either HTML or plain text based on isCommandLine().
         */
        function report() {
-               global $wgLogExceptionBacktrace, $wgMimeType;
-               $log = $this->getLogMessage();
+               global $wgMimeType;
 
-               if ( $log ) {
-                       if ( $wgLogExceptionBacktrace ) {
-                               wfDebugLog( 'exception', $log . "\n" . 
$this->getTraceAsString() . "\n" );
-                       } else {
-                               wfDebugLog( 'exception', $log );
-                       }
-               }
+               $this->logException();
 
                if ( defined( 'MW_API' ) ) {
                        // Unhandled API exception, we can't be sure that 
format printer is alive
@@ -274,6 +267,22 @@
        }
 
        /**
+        * Log the error message to the exception log (if enabled)
+        */
+       function logException() {
+               global $wgLogExceptionBacktrace;
+
+               $log = $this->getLogMessage();
+               if ( $log ) {
+                       if ( $wgLogExceptionBacktrace ) {
+                               wfDebugLog( 'exception', $log . "\n" . 
$this->getTraceAsString() . "\n" );
+                       } else {
+                               wfDebugLog( 'exception', $log );
+                       }
+               }
+       }
+
+       /**
         * Check whether we are in command line mode or not to report the 
exception
         * in the correct format.
         *
diff --git a/includes/resourceloader/ResourceLoader.php 
b/includes/resourceloader/ResourceLoader.php
index ff3ea35..3088370 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -177,6 +177,7 @@
                        // Save filtered text to Memcached
                        $cache->set( $key, $result );
                } catch ( Exception $exception ) {
+                       $exception->logException();
                        wfDebugLog( 'resourceloader', __METHOD__ . ": 
minification failed: $exception" );
                        $this->hasErrors = true;
                        // Return exception as a comment
@@ -474,6 +475,7 @@
                try {
                        $this->preloadModuleInfo( array_keys( $modules ), 
$context );
                } catch ( Exception $e ) {
+                       $e->logException();
                        wfDebugLog( 'resourceloader', __METHOD__ . ": 
preloading module info failed: $e" );
                        $this->hasErrors = true;
                        // Add exception to the output as a comment
@@ -493,6 +495,7 @@
                                // Calculate maximum modified time
                                $mtime = max( $mtime, $module->getModifiedTime( 
$context ) );
                        } catch ( Exception $e ) {
+                               $e->logException();
                                wfDebugLog( 'resourceloader', __METHOD__ . ": 
calculating maximum modified time failed: $e" );
                                $this->hasErrors = true;
                                // Add exception to the output as a comment
@@ -727,6 +730,7 @@
                        try {
                                $blobs = MessageBlobStore::get( $this, 
$modules, $context->getLanguage() );
                        } catch ( Exception $e ) {
+                               $e->logException();
                                wfDebugLog( 'resourceloader', __METHOD__ . ": 
pre-fetching blobs from MessageBlobStore failed: $e" );
                                $this->hasErrors = true;
                                // Add exception to the output as a comment
@@ -834,6 +838,7 @@
                                                break;
                                }
                        } catch ( Exception $e ) {
+                               $e->logException();
                                wfDebugLog( 'resourceloader', __METHOD__ . ": 
generating module package failed: $e" );
                                $this->hasErrors = true;
                                // Add exception to the output as a comment

-- 
To view, visit https://gerrit.wikimedia.org/r/83119
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icb479c76cd855244429fe65b29667783dcca8f53
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Trevor Parscal <tpars...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to