Project

General

Profile

Feature #10129 ยป net-http-error-message.diff

xshay (Xavier Shay), 08/13/2014 10:36 PM

View differences:

lib/net/http.rb
876 876

  
877 877
      D "opening connection to #{conn_address}:#{conn_port}..."
878 878
      s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
879
        TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
879
        begin
880
          TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
881
        rescue => e
882
          raise e, "Failed to open TCP connection to " +
883
            "#{conn_address}:#{conn_port} (#{e.message})"
884
        end
880 885
      }
881 886
      s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
882 887
      D "opened"
test/net/http/test_http.rb
189 189
    end
190 190
  end
191 191

  
192
  def test_failure_message_includes_failed_domain_and_port
193
    begin
194
      Net::HTTP.get(URI.parse("http://doesnotexist.bogus"))
195
      fail "should have raised"
196
    rescue => e
197
      assert_includes e.message, "doesnotexist.bogus:80"
198
    end
199
  end
200

  
192 201
end
193 202

  
194 203
module TestNetHTTP_version_1_1_methods