/**
  * @param Exception|Throwable $e Original exception
  * @param integer $mode MWExceptionExposer::AS_* constant
  * @param Exception|Throwable|null $eNew New exception from attempting to show the first
  */
 public static function output($e, $mode, $eNew = null)
 {
     global $wgMimeType;
     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));
         wfHttpError(500, 'Internal Server Error', self::getText($e));
     } elseif (self::isCommandLine()) {
         self::printError(self::getText($e));
     } elseif ($mode === self::AS_PRETTY) {
         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";
             if (self::showBackTrace($e)) {
                 $message .= 'Original exception: ' . MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($e) . "\n\nException caught inside exception handler: " . MWExceptionHandler::getLogMessage($eNew) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($eNew);
             } 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";
         } else {
             if (self::showBackTrace($e)) {
                 $message = MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($e) . "\n";
             } else {
                 $message = MWExceptionHandler::getPublicLogMessage($e);
             }
         }
         if (self::isCommandLine()) {
             self::printError($message);
         } else {
             echo nl2br(htmlspecialchars($message)) . "\n";
         }
     }
 }
Beispiel #2
0
 /**
  * Handle exception display.
  *
  * @since 1.25
  * @param Exception $e Exception to be shown to the user
  * @return string Sanitized text that can be returned to the user
  */
 protected static function formatExceptionNoComment($e)
 {
     global $wgShowExceptionDetails;
     if (!$wgShowExceptionDetails) {
         return MWExceptionHandler::getPublicLogMessage($e);
     }
     return MWExceptionHandler::getLogMessage($e);
 }