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

Fix error handling post-migration to immutable messages #23

Merged
merged 3 commits into from
Jan 20, 2015

Conversation

weierophinney
Copy link
Contributor

Following the change to use immutable messages, error handlers largely stopped working. This was due to the fact that they were not receiving the current message instances -- and thus could not pull up-to-date data from them.

This patch does the following:

  • FinalHandler now no longer accepts the request/response instances to the constructor, but rather expects them to __invoke as the second and third methods -- just like normal error middleware, but without the final callable.
  • Next now passes the current request/response instances to error handlers.
  • Next now passes the current request/response instances to the final handler.
  • Next now also allows passing both the request and response when specifying an error.

One upshot: unless you are performing processing AFTER calling $next(), you should return its return value to ensure the chain completes properly. This, in the end, is a more functional paradigm, as the chain and application no longer rely on side effects, but explicit return values.

@weierophinney weierophinney merged commit ad7a65c into phly:master Jan 20, 2015
weierophinney added a commit that referenced this pull request Jan 20, 2015
@weierophinney weierophinney deleted the feature/done-callback branch January 20, 2015 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant