50 parent::__construct( $content );
51 $this->httpCode = (int)$httpCode;
53 $this->content = $content;
75 return $this->httpCode;
86 HttpStatus::header( $this->httpCode );
87 header(
'Content-type: text/html; charset=utf-8' );
92 private function doLog() {
93 $logger = LoggerFactory::getInstance(
'HttpError' );
94 $content = $this->content;
96 if ( $content instanceof
Message ) {
97 $content = $content->
text();
102 'line' => $this->getLine(),
103 'http_code' => $this->httpCode,
106 $logMsg =
"$content ({http_code}) from {file}:{line}";
109 $logger->info( $logMsg, $context );
111 $logger->error( $logMsg, $context );
122 if ( $this->header ===
null ) {
123 $titleHtml = htmlspecialchars( HttpStatus::getMessage( $this->httpCode ) );
124 } elseif ( $this->header instanceof
Message ) {
125 $titleHtml = $this->header->escaped();
127 $titleHtml = htmlspecialchars( $this->header );
130 if ( $this->content instanceof
Message ) {
131 $contentHtml = $this->content->escaped();
133 $contentHtml = nl2br( htmlspecialchars( $this->content ) );
136 return "<!DOCTYPE html>\n" .
137 "<html><head><title>$titleHtml</title><meta name=\"color-scheme\" content=\"light dark\" /></head>\n" .
138 "<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.