Go to the documentation of this file.
38 public static function output( $e, $mode, $eNew =
null ) {
41 if ( defined(
'MW_API' ) ) {
43 self::header(
'MediaWiki-API-Error: internal_api_error_' . get_class( $e ) );
44 wfHttpError( 500,
'Internal Server Error', self::getText( $e ) );
45 } elseif ( self::isCommandLine() ) {
47 } elseif ( $mode === self::AS_PRETTY ) {
49 self::header(
"Content-Type: $wgMimeType; charset=utf-8" );
57 self::header(
"Content-Type: $wgMimeType; charset=utf-8" );
59 $message =
"MediaWiki internal error.\n\n";
61 $message .=
'Original exception: ' .
64 "\n\nException caught inside exception handler: " .
68 $message .=
'Original exception: ' .
70 $message .=
"\n\nException caught inside exception handler.\n\n" .
81 echo nl2br( htmlspecialchars( $message ) ) .
"\n";
91 foreach ( $e->getTrace() as $frame ) {
92 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
102 !empty(
$GLOBALS[
'wgFullyInitialised'] ) &&
105 !defined(
'MEDIAWIKI_INSTALL' )
117 if ( self::useOutputPage( $e ) ) {
119 $wgOut->prepareErrorPage( $e->getPageTitle() );
121 $wgOut->prepareErrorPage( self::msg(
'readonly',
'Database is locked' ) );
123 $wgOut->prepareErrorPage( self::msg(
'databaseerror',
'Database error' ) );
125 $wgOut->prepareErrorPage( self::msg(
'internalerror',
'Internal error' ) );
130 $wgOut->addHTML( Html::element(
'p', [], Message::newFromSpecifier( $e )->text() ) );
132 $wgOut->addHTML( self::getHTML( $e ) );
136 self::header(
'Content-Type: text/html; charset=utf-8' );
137 $pageTitle =
self::msg(
'internalerror',
'Internal error' );
138 echo
"<!DOCTYPE html>\n" .
142 htmlspecialchars( self::msg(
'pagetitle',
"$1 - $wgSitename", $pageTitle ) ) .
144 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
149 echo
"</body></html>\n";
165 $html =
"<div class=\"errorbox mw-content-ltr\"><p>" .
167 '</p><p>Backtrace:</p><p>' .
172 $html =
"<div class=\"errorbox mw-content-ltr\">" .
174 '[' . $logId .
'] ' .
175 gmdate(
'Y-m-d H:i:s' ) .
": " .
176 self::msg(
"internalerror-fatal-exception",
177 "Fatal exception of type $1",
182 "<!-- " . wordwrap( self::getShowBacktraceError( $e ), 50 ) .
" -->";
203 }
catch ( Exception $e ) {
235 $var =
'$wgShowExceptionDetails = true;';
236 return "Set $var at the bottom of LocalSettings.php to show detailed debugging information.";
243 return !empty(
$GLOBALS[
'wgCommandLineMode'] );
250 if ( !headers_sent() ) {
259 if ( !headers_sent() ) {
275 if ( defined(
'STDERR' ) ) {
276 fwrite( STDERR, $message );
288 $sorry = htmlspecialchars( self::msg(
290 'Sorry! This site is experiencing technical difficulties.'
292 $again = htmlspecialchars( self::msg(
294 'Try waiting a few minutes and reloading.'
300 Html::element(
'span', [
'dir' =>
'ltr' ], $e->getMessage() ),
301 htmlspecialchars( self::msg(
'dberr-info',
'($1)' ) )
304 $info = htmlspecialchars( self::msg(
306 '(Cannot access the database)'
311 $html =
"<!DOCTYPE html>\n" .
316 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
317 "</head><body><h1>$sorry</h1><p>$again</p><p><small>$info</small></p>";
320 $html .=
'<p>Backtrace:</p><pre>' .
321 htmlspecialchars( $e->getTraceAsString() ) .
'</pre>';
324 $html .=
'</body></html>';
$wgMimeType
The default Content-Type header.
static msg( $key, $fallback,... $params)
Get a message from i18n.
$wgShowHostnames
Expose backend server host names through the API and various HTML comments.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static reportOutageHTML( $e)
static getPublicLogMessage( $e)
static getURL()
If the exception occurred in the course of responding to a request, returns the requested URL.
static getLogMessage( $e)
Get a message formatting the exception message and its origin.
static singleton()
Get the singleton instance of this class.
static useOutputPage( $e)
$wgSitename
Name of the site.
static printError( $message)
Print a message, if possible to STDERR.
static getMain()
Get the RequestContext object associated with the main request.
static output( $e, $mode, $eNew=null)
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
static header( $code)
Output an HTTP status code header.
static getRequestId()
Get the unique request ID.
$wgShowExceptionDetails
If set to true, uncaught exceptions will print the exception message and a complete stack trace to ou...
static statusHeader( $code)
static getHTML( $e)
If $wgShowExceptionDetails is true, return a HTML message with a backtrace to the error,...
static reportHTML( $e)
Output the exception report using HTML.
Class to expose exceptions to the client (API bots, users, admins using CLI scripts)
static getRedactedTraceAsString( $e)
Generate a string representation of an exception's stack trace.
static getShowBacktraceError( $e)