38 private function useOutputPage() {
41 !empty( $GLOBALS[
'wgFullyInitialised'] ) &&
42 !empty( $GLOBALS[
'wgOut'] ) &&
43 !defined(
'MEDIAWIKI_INSTALL' ) &&
68 foreach ( $this->getTrace() as $frame ) {
69 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
91 }
catch ( Exception $e ) {
94 if (
$res ===
false ) {
99 '{{SITENAME}}' =>
'MediaWiki',
114 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
115 return '<p>' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) .
116 '</p><p>Backtrace:</p><p>' .
117 nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
120 $logId = WebRequest::getRequestId();
121 $type = static::class;
122 return Html::errorBox(
124 '[' . $logId .
'] ' .
125 gmdate(
'Y-m-d H:i:s' ) .
": " .
126 $this->
msg(
"internalerror-fatal-exception",
127 "Fatal exception of type $1",
130 MWExceptionHandler::getURL()
133 "<!-- Set \$wgShowExceptionDetails = true; " .
134 "at the bottom of LocalSettings.php to show detailed " .
135 "debugging information. -->";
147 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
148 return MWExceptionHandler::getLogMessage( $this ) .
149 "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $this ) .
"\n";
151 return "Set \$wgShowExceptionDetails = true; " .
152 "in LocalSettings.php to show detailed debugging information.\n";
164 return $this->
msg(
'internalerror',
'Internal error' );
173 if ( $this->useOutputPage() ) {
186 self::header(
'Content-Type: text/html; charset=UTF-8' );
187 echo
"<!DOCTYPE html>\n" .
191 htmlspecialchars( $this->
msg(
'pagetitle',
'$1 - MediaWiki', $this->
getPageTitle() ) ) .
193 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
198 echo
"</body></html>\n";
209 if ( defined(
'MW_API' ) ) {
210 self::header(
'MediaWiki-API-Error: internal_api_error_' . static::class );
213 if ( self::isCommandLine() ) {
215 $this->writeToCommandLine( $message );
217 self::statusHeader( 500 );
228 private function writeToCommandLine( $message ) {
230 if ( !defined(
'MW_PHPUNIT_TEST' ) && defined(
'STDERR' ) ) {
231 fwrite( STDERR, $message );
244 return !empty( $GLOBALS[
'wgCommandLineMode'] );
252 private static function header(
$header ) {
253 if ( !headers_sent() ) {
258 private static function statusHeader( $code ) {
259 if ( !headers_sent() ) {
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode $wgOut
static header( $code)
Output an HTTP status code header.
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.
getHTML()
Format an HTML message for the current exception object.
static isCommandLine()
Check whether we are in command line mode or not to report the exception in the correct format.
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()
Format plain text message for the current exception object.