Example #1
0
 /**
  * Report an exception to the user
  * @param Exception|Throwable $e
  */
 protected static function report($e)
 {
     try {
         // Try and show the exception prettily, with the normal skin infrastructure
         if ($e instanceof MWException) {
             // Delegate to MWException until all subclasses are handled by
             // MWExceptionRenderer and MWException::report() has been
             // removed.
             $e->report();
         } else {
             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_RAW, $e2);
     }
 }
 /**
  * Report an exception to the user
  * @param Exception|Throwable $e
  */
 protected static function report($e)
 {
     global $wgShowExceptionDetails;
     $cmdLine = MWException::isCommandLine();
     if ($e instanceof MWException) {
         try {
             // Try and show the exception prettily, with the normal skin infrastructure
             $e->report();
         } catch (Exception $e2) {
             // Exception occurred from within exception handler
             // Show a simpler message for the original exception,
             // don't try to invoke report()
             $message = "MediaWiki internal error.\n\n";
             if ($wgShowExceptionDetails) {
                 $message .= 'Original exception: ' . self::getLogMessage($e) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e) . "\n\nException caught inside exception handler: " . self::getLogMessage($e2) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e2);
             } else {
                 $message .= "Exception caught inside exception handler.\n\n" . "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . "to show detailed debugging information.";
             }
             $message .= "\n";
             if ($cmdLine) {
                 self::printError($message);
             } else {
                 echo nl2br(htmlspecialchars($message)) . "\n";
             }
         }
     } else {
         $message = "Exception encountered, of type \"" . get_class($e) . "\"";
         if ($wgShowExceptionDetails) {
             $message .= "\n" . self::getLogMessage($e) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e) . "\n";
         }
         if ($cmdLine) {
             self::printError($message);
         } else {
             echo nl2br(htmlspecialchars($message)) . "\n";
         }
     }
 }