34 !empty(
$GLOBALS[
'wgFullyInitialised'] ) &&
36 !defined(
'MEDIAWIKI_INSTALL' );
57 foreach ( $this->getTrace() as $frame ) {
58 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
83 }
catch ( Exception $e ) {
86 if (
$res ===
false ) {
108 return '<p>' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) .
109 '</p><p>Backtrace:</p><p>' .
110 nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
113 $logId = WebRequest::getRequestId();
114 $type = static::class;
115 return Html::errorBox(
117 '[' . $logId .
'] ' .
118 gmdate(
'Y-m-d H:i:s' ) .
": " .
119 $this->
msg(
"internalerror-fatal-exception",
120 "Fatal exception of type $1",
123 MWExceptionHandler::getURL()
126 "<!-- Set \$wgShowExceptionDetails = true; " .
127 "at the bottom of LocalSettings.php to show detailed " .
128 "debugging information. -->";
143 return MWExceptionHandler::getLogMessage( $this ) .
144 "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $this ) .
"\n";
146 return "Set \$wgShowExceptionDetails = true; " .
147 "in LocalSettings.php to show detailed debugging information.\n";
157 return $this->
msg(
'internalerror',
'Internal error' );
182 self::header(
'Content-Type: text/html; charset=utf-8' );
183 echo
"<!DOCTYPE html>\n" .
187 htmlspecialchars( $this->
msg(
'pagetitle',
"$1 - $wgSitename", $this->
getPageTitle() ) ) .
189 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
194 echo
"</body></html>\n";
205 if ( defined(
'MW_API' ) ) {
207 self::header(
'MediaWiki-API-Error: internal_api_error_' . static::class );
209 } elseif ( self::isCommandLine() ) {
213 self::statusHeader( 500 );
214 self::header(
"Content-Type: $wgMimeType; charset=utf-8" );
228 if ( !defined(
'MW_PHPUNIT_TEST' ) && defined(
'STDERR' ) ) {
229 fwrite( STDERR, $message );
242 return !empty(
$GLOBALS[
'wgCommandLineMode'] );
251 if ( !headers_sent() ) {
257 if ( !headers_sent() ) {
258 HttpStatus::header( $code );
$wgMimeType
The default Content-Type header.
$wgSitename
Name of the site.
$wgShowExceptionDetails
If set to true, uncaught exceptions will print the exception message and a complete stack trace to ou...
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Internationalisation code.
writeToCommandLine( $message)
Write a message to stderr falling back to stdout if stderr unavailable.
static statusHeader( $code)
isLoggable()
Whether to log this exception in the exception debug log.
useMessageCache()
Can the extension use the Message class/wfMessage to get i18n-ed messages?
msg( $key, $fallback,... $params)
Get a message from i18n.
static header( $header)
Send a header, if we haven't already sent them.
getHTML()
If $wgShowExceptionDetails is true, return a HTML message with a backtrace to the error,...
static isCommandLine()
Check whether we are in command line mode or not to report the exception in the correct format.
useOutputPage()
Should the exception use $wgOut to output the error?
report()
Output a report about the exception and takes care of formatting.
getPageTitle()
Return the title of the page when reporting this error in a HTTP response.
reportHTML()
Output the exception report using HTML.
getText()
Get the text to display when reporting the error on the command line.