48 public function __construct( $httpCode, $content, $header =
null ) {
50 $this->httpCode = (int)$httpCode;
51 $this->header = $header;
74 return $this->httpCode;
85 HttpStatus::header( $this->httpCode );
86 header(
'Content-type: text/html; charset=utf-8' );
91 private function doLog() {
92 $logger = LoggerFactory::getInstance(
'HttpError' );
95 if ( $content instanceof
Message ) {
101 'line' => $this->getLine(),
102 'http_code' => $this->httpCode,
105 $logMsg =
"$content ({http_code}) from {file}:{line}";
108 $logger->info( $logMsg, $context );
110 $logger->error( $logMsg, $context );
121 if ( $this->header ===
null ) {
122 $titleHtml = htmlspecialchars( HttpStatus::getMessage( $this->httpCode ) );
123 } elseif ( $this->header instanceof
Message ) {
124 $titleHtml = $this->header->escaped();
126 $titleHtml = htmlspecialchars( $this->header );
129 if ( $this->content instanceof
Message ) {
130 $contentHtml = $this->content->escaped();
132 $contentHtml = nl2br( htmlspecialchars( $this->content ) );
135 return "<!DOCTYPE html>\n" .
136 "<html><head><title>$titleHtml</title></head>\n" .
137 "<body><h1>$titleHtml</h1><p>$contentHtml</p></body></html>\n";
getFile()
Get the file for this page, if one exists.
Show an error that looks like an HTTP server error.
report()
Report and log the HTTP error.
getStatusCode()
Returns the HTTP status code supplied to the constructor.
__construct( $httpCode, $content, $header=null)
isLoggable()
We don't want the default exception logging as we got our own logging set up in self::report.
getHTML()
Returns HTML for reporting the HTTP error.
The Message class deals with fetching and processing of interface message into a variety of formats.
while(( $__line=Maintenance::readconsole()) !==false) print