Beispiel #1
0
 /**
  * If there are any open database transactions, roll them back and log
  * the stack trace of the exception that should have been caught so the
  * transaction could be aborted properly.
  *
  * @since 1.23
  * @param Exception $e
  */
 public static function rollbackMasterChangesAndLog(Exception $e)
 {
     $factory = wfGetLBFactory();
     if ($factory->hasMasterChanges()) {
         wfDebugLog('Bug56269', 'Exception thrown with an uncommited database transaction: ' . MWExceptionHandler::getLogMessage($e) . "\n" . $e->getTraceAsString());
         $factory->rollbackMasterChanges();
     }
 }
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);
 }
Beispiel #3
0
 /**
  * Report an exception to the user
  */
 protected static function report(Exception $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 error 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 = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class($e) . "\"";
         if ($wgShowExceptionDetails) {
             $message .= "\n" . MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e) . "\n";
         }
         if ($cmdLine) {
             self::printError($message);
         } else {
             echo nl2br(htmlspecialchars($message)) . "\n";
         }
     }
 }
Beispiel #4
0
 /**
  * Get the text to display when reporting the error on the command line.
  * If $wgShowExceptionDetails is true, return a text message with a
  * backtrace to the error.
  *
  * @return string
  */
 public function getText()
 {
     global $wgShowExceptionDetails;
     if ($wgShowExceptionDetails) {
         return MWExceptionHandler::getLogMessage($this) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($this) . "\n";
     } else {
         return "Set \$wgShowExceptionDetails = true; " . "in LocalSettings.php to show detailed debugging information.\n";
     }
 }
 /**
  * Return the requested URL and point to file and line number from which the
  * exception occurred
  *
  * @since 1.8
  * @deprecated since 1.22 Use MWExceptionHandler::getLogMessage instead.
  * @return string
  */
 public function getLogMessage()
 {
     wfDeprecated(__METHOD__, '1.22');
     return MWExceptionHandler::getLogMessage($this);
 }
 /**
  * @param Exception|Throwable $e
  * @return string
  */
 private static function getText($e)
 {
     if (self::showBackTrace($e)) {
         return MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($e) . "\n";
     } else {
         return "Set \$wgShowExceptionDetails = true; " . "in LocalSettings.php to show detailed debugging information.\n";
     }
 }