From a2cb6a405e3665fd249ee5a574cb4f4610610402 Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Tue, 11 Dec 2012 18:56:07 +0400 Subject: [PATCH] Get rid of $this->template logic, switched to type of exception --- app/ErrorAction.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/ErrorAction.php b/app/ErrorAction.php index a4befde..057a272 100644 --- a/app/ErrorAction.php +++ b/app/ErrorAction.php @@ -25,11 +25,12 @@ class ErrorAction extends Action protected function execute() { - $this->template = 500; if ($this->exception instanceof Error404Exception) { $this->template = 404; } elseif ($this->exception instanceof ErrorHTTPException) { $this->template = 'HTTP'; + } else { + $this->template = 500; } $this->logError(); $this->sendHTTPCode(); @@ -50,19 +51,16 @@ class ErrorAction extends Action protected function sendHttpCode() { - switch ($this->template) { - case 404: - case 'HTTP': - header($this->exception->getHTTPHeader()); - break; - default: - header('HTTP/1.0 500 Internal Server Error'); + if ($this->exception instanceof ErrorHTTPException) { + header($this->exception->getHTTPHeader()); + } else { + header('HTTP/1.0 500 Internal Server Error'); } } protected function logError() { - if ($this->template == 500) { + if (!$this->exception instanceof Error404Exception) { ErrorHandler::logError($this->exception); } }