Created
November 16, 2019 06:04
-
-
Save rdp/26f5cde11e8e886b71df5bd42a8730d0 to your computer and use it in GitHub Desktop.
crystal lang #8263
This file contains 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
diff --git a/src/socket/addrinfo.cr b/src/socket/addrinfo.cr | |
index 25e046cda..0ac8867ae 100644 | |
--- a/src/socket/addrinfo.cr | |
+++ b/src/socket/addrinfo.cr | |
@@ -82,12 +82,12 @@ class Socket | |
class Error < Socket::Error | |
getter error_code : Int32 | |
- def self.new(error_code) | |
- new error_code, "getaddrinfo: #{String.new(LibC.gai_strerror(error_code))}" | |
+ def self.new(error_code, domain, service, protocol) | |
+ new error_code, "getaddrinfo: #{String.new(LibC.gai_strerror(error_code))}", domain, service, protocol | |
end | |
- def initialize(@error_code, message) | |
- super(message) | |
+ def initialize(@error_code, message, domain, service, protocol) | |
+ super(message + " for #{domain}:#{service} over #{protocol} when attempting a DNS lookup") | |
end | |
end | |
@@ -121,9 +121,9 @@ class Socket | |
when 0 | |
# success | |
when LibC::EAI_NONAME | |
- raise Error.new(LibC::EAI_NONAME, "No address found for #{domain}:#{service} over #{protocol}") | |
+ raise Error.new(LibC::EAI_NONAME, "No address found", domain, service, protocol) | |
else | |
- raise Error.new(ret) | |
+ raise Error.new(ret, domain, service, protocol) # looks it up gai_strerror | |
end | |
begin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment