39 private function useOutputPage() {
42 !empty( $GLOBALS[
'wgFullyInitialised'] ) &&
43 !empty( $GLOBALS[
'wgOut'] ) &&
44 !defined(
'MEDIAWIKI_INSTALL' ) &&
69 foreach ( $this->getTrace() as $frame ) {
70 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
91 $res =
wfMessage( $key, ...$params )->text();
92 }
catch ( Exception $e ) {
95 if ( $res ===
false ) {
100 '{{SITENAME}}' =>
'MediaWiki',
115 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
116 return '<p>' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) .
117 '</p><p>Backtrace:</p><p>' .
118 nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
121 $logId = WebRequest::getRequestId();
122 $type = static::class;
123 return Html::errorBox(
125 '[' . $logId .
'] ' .
126 gmdate(
'Y-m-d H:i:s' ) .
": " .
127 $this->
msg(
"internalerror-fatal-exception",
128 "Fatal exception of type $1",
131 MWExceptionHandler::getURL()
134 "<!-- Set \$wgShowExceptionDetails = true; " .
135 "at the bottom of LocalSettings.php to show detailed " .
136 "debugging information. -->";
148 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
149 return MWExceptionHandler::getLogMessage( $this ) .
150 "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $this ) .
"\n";
152 return "Set \$wgShowExceptionDetails = true; " .
153 "in LocalSettings.php to show detailed debugging information.\n";
165 return $this->
msg(
'internalerror',
'Internal error' );
174 if ( $this->useOutputPage() ) {
175 $wgOut->prepareErrorPage();
188 self::header(
'Content-Type: text/html; charset=UTF-8' );
189 echo
"<!DOCTYPE html>\n" .
193 htmlspecialchars( $this->
msg(
'pagetitle',
'$1 - MediaWiki', $this->
getPageTitle() ) ) .
195 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
200 echo
"</body></html>\n";
211 if ( defined(
'MW_API' ) ) {
212 self::header(
'MediaWiki-API-Error: internal_api_error_' . static::class );
215 if ( self::isCommandLine() ) {
217 $this->writeToCommandLine( $message );
219 self::statusHeader( 500 );
230 private function writeToCommandLine( $message ) {
232 if ( !defined(
'MW_PHPUNIT_TEST' ) && defined(
'STDERR' ) ) {
233 fwrite( STDERR, $message );
246 return !empty( $GLOBALS[
'wgCommandLineMode'] );
254 private static function header(
$header ) {
255 if ( !headers_sent() ) {
260 private static function statusHeader( $code ) {
261 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.