35 private function useOutputPage() {
38 !empty( $GLOBALS[
'wgFullyInitialised'] ) &&
39 !empty( $GLOBALS[
'wgOut'] ) &&
40 !defined(
'MEDIAWIKI_INSTALL' ) &&
65 foreach ( $this->getTrace() as $frame ) {
66 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
88 }
catch ( Exception $e ) {
91 if (
$res ===
false ) {
96 '{{SITENAME}}' =>
'MediaWiki',
111 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
112 return '<p>' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) .
113 '</p><p>Backtrace:</p><p>' .
114 nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
117 $logId = WebRequest::getRequestId();
118 $type = static::class;
119 return Html::errorBox(
121 '[' . $logId .
'] ' .
122 gmdate(
'Y-m-d H:i:s' ) .
": " .
123 $this->
msg(
"internalerror-fatal-exception",
124 "Fatal exception of type $1",
127 MWExceptionHandler::getURL()
130 "<!-- Set \$wgShowExceptionDetails = true; " .
131 "at the bottom of LocalSettings.php to show detailed " .
132 "debugging information. -->";
144 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
145 return MWExceptionHandler::getLogMessage( $this ) .
146 "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $this ) .
"\n";
148 return "Set \$wgShowExceptionDetails = true; " .
149 "in LocalSettings.php to show detailed debugging information.\n";
161 return $this->
msg(
'internalerror',
'Internal error' );
170 if ( $this->useOutputPage() ) {
183 self::header(
'Content-Type: text/html; charset=UTF-8' );
184 echo
"<!DOCTYPE html>\n" .
188 htmlspecialchars( $this->
msg(
'pagetitle',
'$1 - MediaWiki', $this->
getPageTitle() ) ) .
190 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
195 echo
"</body></html>\n";
206 if ( defined(
'MW_API' ) ) {
207 self::header(
'MediaWiki-API-Error: internal_api_error_' . static::class );
210 if ( self::isCommandLine() ) {
212 $this->writeToCommandLine( $message );
214 self::statusHeader( 500 );
225 private function writeToCommandLine( $message ) {
227 if ( !defined(
'MW_PHPUNIT_TEST' ) && defined(
'STDERR' ) ) {
228 fwrite( STDERR, $message );
241 return !empty( $GLOBALS[
'wgCommandLineMode'] );
249 private static function header(
$header ) {
250 if ( !headers_sent() ) {
255 private static function statusHeader( $code ) {
256 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.