From 1120e310366ba60b476cf8fbd1539647a325421e Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Fri, 9 May 2014 12:10:48 +0100 Subject: [PATCH] Updating exception handler to return the appropriate HTTP response code --- PHPCI/Application.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PHPCI/Application.php b/PHPCI/Application.php index e4532d3b..011e27e5 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -73,11 +73,21 @@ class Application extends b8\Application { try { $this->response = parent::handleRequest(); + } catch (HttpException $ex) { + $this->config->set('page_title', 'Error'); + + $view = new View('exception'); + $view->exception = $ex; + + $this->response->setResponseCode($ex->getErrorCode()); + $this->response->setContent($view->render()); } catch (\Exception $ex) { $this->config->set('page_title', 'Error'); $view = new View('exception'); $view->exception = $ex; + + $this->response->setResponseCode(500); $this->response->setContent($view->render()); }