Project

General

Profile

Feature #13677

Updated by dsbonev (Dimitar Bonev) almost 7 years ago

ruby version: `ruby ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]` [x86_64-linux] 

 ruby script: 

 ~~~ ruby 
 require 'socket' 
 TCPSocket.new 'nonexistent.example.com', 80 
 ~~~ 

 Result: `getaddrinfo: "getaddrinfo: Name or service not known (SocketError)` (SocketError)" 

 Expected: `getaddrinfo: "getaddrinfo: Name or service not known for nonexistent.example.com (SocketError)` (SocketError)" 

 Why: 
 This will make it easier to resolve errors of this kind by just looking at the logged messages. It is common for production and non-production (development, test) code to connect to different hosts which can produce errors due to wrong configuration.  
 This change will make the ruby stdlib code more consistent as other methods already provide useful error information. Some examples: 

 ~~~ ruby 
 host = 'nonexistent.example.com'; port = 80 
 Resolv.getaddress host # => Resolv::ResolvError: no address for nonexistent.example.com 
 Socket.getservbyname host # => SocketError: no such service nonexistent.example.com/tcp 
 Net::HTTP.get Struct.new(:hostname, :port, :scheme).new(host, port, 'http') # => SocketError: Failed to open TCP connection to nonexistent.example.com:80 (getaddrinfo: Name or service not known) 
 ~~~ 

 If this issue will be resolved, please add any useful information to the error message in addition to the host.

Back