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

Support \Throwable when setting previous exception from server callback #155

Merged

Conversation

jsor
Copy link
Member

@jsor jsor commented Mar 30, 2017

Followup for #152

Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

Thanks for spotting! PHP's docs actually allow a Throwable here (checked the German docs before which seem to be outdated currently, duh).

I guess we should also mention this in our README?

@andig
Copy link
Contributor

andig commented Mar 30, 2017

Won't Throwable kill php prior to 7?

@jsor
Copy link
Member Author

jsor commented Mar 30, 2017

@clue What do you mean exactly? This just sets the $previous argument for the emitted \RuntimeException.
@andig Not sure what you mean. Can you elaborate?

@maciejmrozinski
Copy link

@jsor I think, what @andig had in mind, was that Throwable is not defined in PHP < 7.0 and how such situation will be handled - fatal or just false statement.

@andig For PHP < 7.0 it will just evaluate to false.

@andig
Copy link
Contributor

andig commented Mar 30, 2017

@maciejmrozinski Indeed, verified using l3v4.

@jsor
Copy link
Member Author

jsor commented Mar 31, 2017

@maciejmrozinski Thanks for the clarification! Yes, with PHP5 \Throwable just isn't declared and the instanceof check will evaluate to false.

Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

The changes LGTM, should this be mentioned in the README (see error event)?

@jsor
Copy link
Member Author

jsor commented Apr 10, 2017

The question is rather if we should completely switch over to use \Throwable as type hints in the documentations across our components?

@NanoSector
Copy link

NanoSector commented Jun 21, 2017

Hit this wall too. Setting this up would mean stuff like \Error would get passed to the previous exception parameter too, and therefore generic PHP errors can be found.

@clue
Copy link
Member

clue commented Jun 21, 2017

I agree that we should get this in, but we should make sure this is mentioned in the README (which only mentions Exception currently). Ultimately we may want to switch to Throwable only, but that would involve dropping PHP < 7.0, which I'd rather discuss separately (reactphp/reactphp#374) 👍

@jsor
Copy link
Member Author

jsor commented Jun 22, 2017

I agree that we should get this in, but we should make sure this is mentioned in the README (which only mentions Exception currently).

@clue Yes, and that is correct because the server will always emit a \RuntimeException. This patch only handles the $previous argument for this exception.

@clue
Copy link
Member

clue commented Jun 22, 2017

[…] the server will always emit a \RuntimeException. This patch only handles the $previous argument for this exception.

I think this should be mentioned in the README 👍

In particular, it currently says (emphasis mine):

The server will also emit an error event if you return an invalid type in the callback function or have a unhandled Exception. If your callback function throws an exception, the Server will emit a RuntimeException and add the thrown exception as previous:

@jsor
Copy link
Member Author

jsor commented Jul 4, 2017

To properly support Throwables, react/promise: ^2.3 is required as that version introduced support for it.

Should we bump the version in composer.json or add a note to the readme?

@WyriHaximus
Copy link
Member

@jsor bumping sounds like a good idea to me 👍

@clue clue added this to the v0.7.3 milestone Jul 15, 2017
@clue clue merged commit d1ee39a into reactphp:master Jul 15, 2017
@WyriHaximus
Copy link
Member

🎉

@jsor jsor deleted the throwable-in-server-callback-rejection branch July 15, 2017 11:56
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.

6 participants