"</p>\n";
} else {
$logId = WebRequest::getRequestId();
- $type = get_class( $this );
+ $type = static::class;
return "<div class=\"errorbox\">" .
'[' . $logId . '] ' .
gmdate( 'Y-m-d H:i:s' ) . ": " .
if ( $this->useOutputPage() ) {
$wgOut->prepareErrorPage( $this->getPageTitle() );
- $hookResult = $this->runHooks( get_class( $this ) );
+ $hookResult = $this->runHooks( static::class );
if ( $hookResult ) {
$wgOut->addHTML( $hookResult );
} else {
'<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
"</head><body>\n";
- $hookResult = $this->runHooks( get_class( $this ) . 'Raw' );
+ $hookResult = $this->runHooks( static::class . 'Raw' );
if ( $hookResult ) {
echo $hookResult;
} else {
* It will be either HTML or plain text based on isCommandLine().
*/
public function report() {
- MWExceptionRenderer::output( $this, MWExceptionRenderer::AS_PRETTY );
+ global $wgMimeType;
+
+ if ( defined( 'MW_API' ) ) {
+ // Unhandled API exception, we can't be sure that format printer is alive
+ self::header( 'MediaWiki-API-Error: internal_api_error_' . static::class );
+ wfHttpError( 500, 'Internal Server Error', $this->getText() );
+ } elseif ( self::isCommandLine() ) {
+ $message = $this->getText();
+ // T17602: STDERR may not be available
+ if ( defined( 'STDERR' ) ) {
+ fwrite( STDERR, $message );
+ } else {
+ echo $message;
+ }
+ } else {
+ self::statusHeader( 500 );
+ self::header( "Content-Type: $wgMimeType; charset=utf-8" );
+
+ $this->reportHTML();
+ }
}
/**