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

Improve error messages for failed connections to include errno #271

Merged
merged 7 commits into from
Sep 11, 2021

Conversation

clue
Copy link
Member

@clue clue commented Sep 6, 2021

This changeset improves error messages for failed connections to include the errno (the internal error number exposed by the underlying system functions and its constant name).

- Connection to tcp://localhost:80 cancelled during DNS lookup
- Connection to tcp://localhost:80 failed: Last error for IPv4: Connection to tcp://127.0.0.1:80 failed: Connection refused. Previous error for IPv6: Connection to tcp://[::1]:80 failed: Connection refused
+ Connection to tcp://localhost:80 cancelled during DNS lookup (ECONNABORTED)
+ Connection to tcp://localhost:80 failed: Last error for IPv4: Connection to tcp://127.0.0.1:80 failed: Connection refused (ECONNREFUSED). Previous error for IPv6: Connection to tcp://[::1]:80 failed: Connection refused (ECONNREFUSED)

The errno value describes the type of error that has been encountered. This value is exposed by a number of system functions but not always exposed by many higher-level PHP functions. This changeset implements a number of ways to report or look up the errno value based on the errstr and find a matching errno constant name. This can be useful to provide more context and more descriptive error messages. The specific error conditions and codes used are system specific and in many cases are only exposed when ext-sockets is available (which is entirely optional, but the default on most installations of PHP).

Builds on top of #270, #265, #266, #267 and others such as clue/reactphp-redis#116, friends-of-reactphp/mysql#141 and more

@clue clue added this to the v1.10.0 milestone Sep 6, 2021
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.

None yet

2 participants