* Redundant script that isn't used by anything
[lhc/web/wiklou.git] / includes / Exception.php
index 027c5d3..ac9c8a2 100644 (file)
@@ -20,16 +20,28 @@ class MWException extends Exception
                        return wfMsgReplaceArgs( $fallback, $args );
                }
        }
-                       
+
        function getHTML() {
-               return '<p>' . htmlspecialchars( $this->getMessage() ) . 
-                       '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
-                       "</p>\n";
+               global $wgShowExceptionDetails;
+               if( $wgShowExceptionDetails ) {
+                       return '<p>' . htmlspecialchars( $this->getMessage() ) . 
+                               '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
+                               "</p>\n";
+               } else {
+                       return "<p>Set <b><tt>\$wgShowExceptionDetails = true;</tt></b> " .
+                               "in LocalSettings.php to show detailed debugging information.</p>";
+               }
        }
 
        function getText() {
-               return $this->getMessage() .
-                       "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
+               global $wgShowExceptionDetails;
+               if( $wgShowExceptionDetails ) {
+                       return $this->getMessage() .
+                               "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
+               } else {
+                       return "<p>Set <tt>\$wgShowExceptionDetails = true;</tt> " .
+                               "in LocalSettings.php to show detailed debugging information.</p>";
+               }
        }
        
        function getPageTitle() {
@@ -41,6 +53,13 @@ class MWException extends Exception
                }
        }
        
+       function getLogMessage() {
+               $file = $this->getFile();
+               $line = $this->getLine();
+               $message = $this->getMessage();
+               return "{$_SERVER['REQUEST_URI']} Exception from line $line of $file: $message";
+       }
+       
        function reportHTML() {
                global $wgOut;
                if ( $this->useOutputPage() ) {
@@ -68,6 +87,10 @@ class MWException extends Exception
                if ( $wgCommandLineMode ) {
                        $this->reportText();
                } else {
+                       $log = $this->getLogMessage();
+                       if ( $log ) {
+                               wfDebugLog( 'exception', $log );
+                       }
                        $this->reportHTML();
                }
        }
@@ -95,6 +118,7 @@ class MWException extends Exception
        function htmlFooter() {
                echo "</body></html>";
        }
+
 }
 
 /**
@@ -141,7 +165,7 @@ function wfInstallExceptionHandler() {
  * Report an exception to the user
  */
 function wfReportException( Exception $e ) {
-        if ( is_a( $e, 'MWException' ) ) {
+        if ( $e instanceof MWException ) {
                 try {
                         $e->report();
                 } catch ( Exception $e2 ) {