Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Application::handleRequest now properly displays exceptions. #976

wants to merge 2 commits into from

Conversation

Adirelle
Copy link
Contributor

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.

@Adirelle
Copy link
Contributor Author

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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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;
Copy link
Collaborator

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)

@mavimo
Copy link
Collaborator

mavimo commented May 18, 2015

This should not merge since the b8 framework fix was added.

@Adirelle
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants