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

Refactor Socket::Addrinfo::Error based on os_error #10761

Merged

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented May 29, 2021

Addrinfo::Error used to have an extra ivar error_code to keep track of the error code. This patch refactors the class to use SystemError#os_error and the associated factory methods instead, which is exactly made for this purpose.
Addrinfo::Error already inherits SystemError through Socket::Error, so this doesn't change the type hierarchy.

As a result, Addrinfo::Error#value and the Addrinfo constructors receiving a plain Int32 error code are being deprecated (they keep working as delegates to the respective SystemError methods.

A necessary addition to SystemError (first commit) is the factory method .os_error_message which allows customization of the error message constructed from the os_error value (which was previously hardcoded to os_error.message). This allows incorporation of opts values into the message.

Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

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

Nice refactor <2

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.

2 participants