Updating exception handler to return the appropriate HTTP response code
This commit is contained in:
parent
b146af66b7
commit
baee67a43b
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue