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

[RTM] Rework the exception listeners #214

Merged
merged 21 commits into from Apr 17, 2015
Merged

Conversation

leofeyer
Copy link
Member

This is the PR regarding our exception listener discussion yesterday. There are now three exception listeners:

  • ResponseExceptionListener: takes care of all response exceptions.
  • ExceptionConverterListener: converts runtime exceptions into HTTP exceptions.
  • PrettyErrorScreenListener: converts HTTP exceptions into pretty error screens.

@leofeyer leofeyer added this to the 4.0.0 milestone Apr 16, 2015
];

/**
* Adds the referer ID to the request.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maps known exceptions to HTTP exceptions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if my "?" was not clear enough: the method description is wrong ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know and I suggested to use "Maps known exceptions to HTTP exceptions" instead. You like?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sure that would work.

tags:
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException }
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 64 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to set priorities at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it is vital that the exception converter listener comes before the pretty error screen listener?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, as we are running the same chain again (and not pass our converted exception to the next listener).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, nope.

@@ -325,12 +325,12 @@ private function validateInstallation(Request $request = null)

// Show the "insecure document root" message
if (!in_array($request->getClientIp(), ['127.0.0.1', 'fe80::1', '::1']) && '/web' === substr($request->getBasePath(), -4)) {
throw new InsecureInstallationHttpException(null, 'Your installation is not secure. Please set the document root to the <code>/web</code> subfolder.');
throw new InsecureInstallationException('Your installation is not secure. Please set the document root to the <code>/web</code> subfolder.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now also should remove the <code> tag from the message as it is not an http exception anymore.

{
$this->response = $response;

parent::__construct($response->getContent(), 0, $previous);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bad as the content of the response may be changed but the message not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b920073.

@leofeyer leofeyer changed the title [RFC] Rework the exception listeners [RTM] Rework the exception listeners Apr 16, 2015
@leofeyer
Copy link
Member Author

I have updated the status to RTM.

@leofeyer leofeyer self-assigned this Apr 16, 2015
@leofeyer leofeyer merged commit 6695ad0 into develop Apr 17, 2015
@leofeyer leofeyer deleted the feature/exception-listener branch April 17, 2015 07:50
leofeyer added a commit that referenced this pull request Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants