-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application::handleRequest now properly displays exceptions. #976
Conversation
Combined with Block8/b8framework#41 (on the 1.x version of the framework), this allows to gracefully handle "not found" exceptions. |
} catch (\Exception $ex) { | ||
$this->config->set('page_title', 'Error'); | ||
|
||
$view = new View('exception'); | ||
$view->exception = $ex; | ||
|
||
$this->response->setResponseCode(500); | ||
$this->response->setResponseCode($ex instanceof HttpException ? $ex->getErrorCode() : 500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure have a condition check here is good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only differences between the two catch blocks. If HttpException used/overrode Exception::getCode instead of defining its own getErrorCode, this checks wouldn't even be necessary.
|
||
$view = new View('exception'); | ||
$view->exception = $ex; | ||
return $this->respone; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, should be $this->response
(missing S)
This should not merge since the b8 framework fix was added. |
The PR fixes all exception handling on its own; it doesn't depend on the b8framework PR, which just sends a proper 404 HttpException instead of a PHP error. |
Contribution Type: bug fix
Primary Area: front-end
Link to Bug: #960, #929, #719.
Description of change: properly display exceptions happening while handling a request.
Description of solution: modified Application::handleRequest.