Repository navigation
Improve error reporting when custom error handler is used - #28
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation and regression test address the reported behavior with no identified blocking issues.
No open issues 🎉
What changed in this PR
Improves multicast receiver error reporting so custom PHP error handlers do not intercept join-group warnings, while preserving the documented RuntimeException.
Changes:
- Suppresses warnings during multicast group joining and restores the previous error handler afterward.
- Includes the socket error reason and code in exceptions, with regression coverage.
| File | Description |
|---|---|
| tests/FunctionalTest.php | Verifies exception details and that the custom error handler is not called. |
| src/Factory.php | Suppresses join-group warnings and adds underlying socket error details to exceptions. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changeset improves error reporting when custom error handler is used (
set_error_handler()), as discussed in reactphp/socket#290. Joining a multicast group could report a PHP warning before throwing, so a custom error handler would see this warning and one converting warnings to exceptions would throw anErrorExceptioninstead of the documentedRuntimeException. This has been the case since #6 switched to the stream based API in v0.2.0 (2015).The
RuntimeExceptionnow also includes the underlying error reason and code, such asUnable to join multicast group: Invalid argumentwith code22(EINVAL). Otherwise, the behavior is unchanged.Builds on top of #6 and reactphp/socket#290