MWException: Cleanup exception message output
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 1 Nov 2013 18:46:19 +0000 (14:46 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 1 Nov 2013 18:46:19 +0000 (14:46 -0400)
Change I0a9e9244 lost the message when handling a non-MWException
exception, and for a long time MWException's getHTML and getText have
been missing the actual file and line where the exception was thrown.

We may as well use MWExceptionHandler::getLogMessage to fix all of
these, resulting in a more standardized exception output.

Change-Id: I8a9b4831c9c586bafe0a54516ff779cdfb008984

includes/Exception.php

index 9623a84..ac98564 100644 (file)
@@ -140,7 +140,7 @@ class MWException extends Exception {
                global $wgShowExceptionDetails;
 
                if ( $wgShowExceptionDetails ) {
-                       return '<p>' . nl2br( htmlspecialchars( $this->getMessage() ) ) .
+                       return '<p>' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) .
                                '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
                                "</p>\n";
                } else {
@@ -165,7 +165,7 @@ class MWException extends Exception {
                global $wgShowExceptionDetails;
 
                if ( $wgShowExceptionDetails ) {
-                       return $this->getMessage() .
+                       return MWExceptionHandler::getLogMessage( $this ) .
                                "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $this ) . "\n";
                } else {
                        return "Set \$wgShowExceptionDetails = true; " .
@@ -641,8 +641,7 @@ class MWExceptionHandler {
                                get_class( $e ) . "\"";
 
                        if ( $wgShowExceptionDetails ) {
-                               $message .= "\nexception '" . get_class( $e ) . "' in " .
-                                       $e->getFile() . ":" . $e->getLine() . "\nStack trace:\n" .
+                               $message .= "\n" . MWExceptionHandler::getLogMessage( $e ) . "\nBacktrace:\n" .
                                        self::getRedactedTraceAsString( $e ) . "\n";
                        }