Exception rendering fixes
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 30 Sep 2016 23:57:38 +0000 (16:57 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 30 Sep 2016 23:57:48 +0000 (16:57 -0700)
* Actually use MWExceptionRenderer::AS_RAW. Use this after
  an error is thrown while trying to pretty render the original
  error. This is how this case was originally handled before.
* Do not show the google form or file cache in CLI mode.

Change-Id: I130499753efbf8b4d6d254ea36bacb2473952c1b

includes/exception/MWExceptionHandler.php
includes/exception/MWExceptionRenderer.php

index 797b3af..4a1f190 100644 (file)
@@ -68,14 +68,13 @@ class MWExceptionHandler {
                                // removed.
                                $e->report();
                        } else {
-                               MWExceptionRenderer::output(
-                                       $e, MWExceptionRenderer::AS_PRETTY );
+                               MWExceptionRenderer::output( $e, MWExceptionRenderer::AS_PRETTY );
                        }
                } catch ( Exception $e2 ) {
                        // Exception occurred from within exception handler
                        // Show a simpler message for the original exception,
                        // don't try to invoke report()
-                       MWExceptionRenderer::output( $e, MWExceptionRenderer::AS_PRETTY, $e2 );
+                       MWExceptionRenderer::output( $e, MWExceptionRenderer::AS_RAW, $e2 );
                }
        }
 
index aba131d..8fdc417 100644 (file)
@@ -35,11 +35,6 @@ class MWExceptionRenderer {
        public static function output( $e, $mode, $eNew = null ) {
                global $wgMimeType;
 
-               if ( $e instanceof DBConnectionError ) {
-                       self::reportOutageHTML( $e );
-                       return;
-               }
-
                if ( defined( 'MW_API' ) ) {
                        // Unhandled API exception, we can't be sure that format printer is alive
                        self::header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $e ) );
@@ -47,9 +42,13 @@ class MWExceptionRenderer {
                } elseif ( self::isCommandLine() ) {
                        self::printError( self::getText( $e ) );
                } elseif ( $mode === self::AS_PRETTY ) {
-                       self::statusHeader( 500 );
-                       self::header( "Content-Type: $wgMimeType; charset=utf-8" );
-                       self::reportHTML( $e );
+                       if ( $e instanceof DBConnectionError ) {
+                               self::reportOutageHTML( $e );
+                       } else {
+                               self::statusHeader( 500 );
+                               self::header( "Content-Type: $wgMimeType; charset=utf-8" );
+                               self::reportHTML( $e );
+                       }
                } else {
                        if ( $eNew ) {
                                $message = "MediaWiki internal error.\n\n";