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 Socket::Connect error in addrinfo inherit os_error #10782

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/socket/addrinfo.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Socket

unless addrinfo = addrinfo.try(&.next?)
if error.is_a?(Socket::ConnectError)
raise Socket::ConnectError.from_errno("Error connecting to '#{domain}:#{service}'")
raise Socket::ConnectError.from_os_error("Error connecting to '#{domain}:#{service}'", error.os_error)
else
raise error if error
end
Expand All @@ -96,7 +96,7 @@ class Socket
new error_code, nil, domain: domain
end

protected def self.new_from_os_error(message : String, os_error, *, domain, type, service, protocol, **opts)
protected def self.new_from_os_error(message : String?, os_error, *, domain, type, service, protocol, **opts)
new(message, **opts)
end

Expand Down
4 changes: 2 additions & 2 deletions src/system_error.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# Prepares the message that goes before the system error description.
# By default it returns the original message unchanged. But that could be
# customized based on the keyword arguments passed to `from_errno` or `from_winerror`.
# * `protected def new_from_os_error(message : String, os_error, **opts)`
# * `protected def new_from_os_error(message : String?, os_error, **opts)`
# Creates an instance of the exception that wraps a system error.
# This is a factory method and by default it creates an instance
# of the current class. It can be overridden to generate different
Expand Down Expand Up @@ -103,7 +103,7 @@ module SystemError
# This is a factory method and by default it creates an instance
# of the current class. It can be overridden to generate different
# classes based on the `os_error` value or keyword arguments.
protected def new_from_os_error(message : String, os_error, **opts)
protected def new_from_os_error(message : String?, os_error, **opts)
self.new(message, **opts)
end

Expand Down