summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 01:38:59 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 01:38:59 +0000
commita84bfcbf0061d30946e4d9692e9d4fa70682aef4 (patch)
tree41b3c94f7648640d256a0619a4ad24318da64931 /lib
parent2758be26bb21be9acfd8720bb8160dab2ddc363e (diff)
* lib/net/http.rb: More descriptive error message when net/http fails
to connect to a server. Patch by @xaviershay [fix GH-700] * test/net/http/test_http.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/http.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 03823ae735..37b6b82694 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -876,7 +876,12 @@ module Net #:nodoc:
D "opening connection to #{conn_address}:#{conn_port}..."
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
- TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
+ begin
+ TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
+ rescue => e
+ raise e, "Failed to open TCP connection to " +
+ "#{conn_address}:#{conn_port} (#{e.message})"
+ end
}
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
D "opened"