Skip to content

Commit ce9ac47

Browse files
authored
Merge pull request #263 from shioimm/catch-ETIMEDOUT-or-IOTimeoutError
Raise `Net::OpenTimeout` when `TCPSocket.open` raises `IO::TimeoutError`.
2 parents 3ccf0c8 + f64109e commit ce9ac47

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/net/http.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,9 @@ def connect
16761676
begin
16771677
s = timeouted_connect(conn_addr, conn_port)
16781678
rescue => e
1679-
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
1679+
if (defined?(IO::TimeoutError) && e.is_a?(IO::TimeoutError)) || e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
1680+
e = Net::OpenTimeout.new(e)
1681+
end
16801682
raise e, "Failed to open TCP connection to " +
16811683
"#{conn_addr}:#{conn_port} (#{e.message})"
16821684
end

0 commit comments

Comments
 (0)