Updating exception handler to return the appropriate HTTP response code

This commit is contained in:
Dan Cryer 2014-05-09 12:10:48 +01:00
parent 22b1245e9b
commit 1120e31036

View file

@ -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());
}