Get rid of $this->template logic, switched to type of exception
This commit is contained in:
@ -25,11 +25,12 @@ class ErrorAction extends Action
|
|||||||
|
|
||||||
protected function execute()
|
protected function execute()
|
||||||
{
|
{
|
||||||
$this->template = 500;
|
|
||||||
if ($this->exception instanceof Error404Exception) {
|
if ($this->exception instanceof Error404Exception) {
|
||||||
$this->template = 404;
|
$this->template = 404;
|
||||||
} elseif ($this->exception instanceof ErrorHTTPException) {
|
} elseif ($this->exception instanceof ErrorHTTPException) {
|
||||||
$this->template = 'HTTP';
|
$this->template = 'HTTP';
|
||||||
|
} else {
|
||||||
|
$this->template = 500;
|
||||||
}
|
}
|
||||||
$this->logError();
|
$this->logError();
|
||||||
$this->sendHTTPCode();
|
$this->sendHTTPCode();
|
||||||
@ -50,19 +51,16 @@ class ErrorAction extends Action
|
|||||||
|
|
||||||
protected function sendHttpCode()
|
protected function sendHttpCode()
|
||||||
{
|
{
|
||||||
switch ($this->template) {
|
if ($this->exception instanceof ErrorHTTPException) {
|
||||||
case 404:
|
header($this->exception->getHTTPHeader());
|
||||||
case 'HTTP':
|
} else {
|
||||||
header($this->exception->getHTTPHeader());
|
header('HTTP/1.0 500 Internal Server Error');
|
||||||
break;
|
|
||||||
default:
|
|
||||||
header('HTTP/1.0 500 Internal Server Error');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function logError()
|
protected function logError()
|
||||||
{
|
{
|
||||||
if ($this->template == 500) {
|
if (!$this->exception instanceof Error404Exception) {
|
||||||
ErrorHandler::logError($this->exception);
|
ErrorHandler::logError($this->exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user