Feature #10129

More descriptive error message for failed net/http requests

Added by Xavier Shay 9 months ago. Updated 8 months ago.

[ruby-core:64347]
Status:Assigned
Priority:Low
Assignee:Akira Tanaka

Description

Hello,
I would like to propose the following patch:

Before

2.1.2 :003 > Net::HTTP.get(URI.parse("https://arsrtrtrstsrt.com/arstr"))
SocketError: getaddrinfo: nodename nor servname provided, or not known

After

2.1.2 :003 > Net::HTTP.get(URI.parse("https://arsrtrtrstsrt.com/arstr"))
SocketError: Failed to open TCP connection to arsrtrtrstsrt.com:443 (getaddrinfo: nodename nor servname provided, or not known)

I have an implementation with test at https://github.com/ruby/ruby/pull/700

Thank you for your consideration,
Xavier

net-http-error-message.diff Magnifier (1.43 KB) Xavier Shay, 08/13/2014 10:36 PM

History

#1 Updated by Xavier Shay 9 months ago

Attaching diff, possibly more useful than github PR.

#2 Updated by Nobuyoshi Nakada 8 months ago

  • Category set to ext
  • Status changed from Open to Assigned
  • Assignee set to Akira Tanaka
  • Target version set to current: 2.2.0

Shouldn't Socket methods raise more descriptive messages?

https://github.com/nobu/ruby/compare/socket-error-message

#3 Updated by Eric Wong 8 months ago

nobu@ruby-lang.org wrote:

Shouldn't Socket methods raise more descriptive messages?

https://github.com/nobu/ruby/compare/socket-error-message

Yes. I think the EAI_SYSTEM case should also include host/port in the
error message, too.

#4 Updated by Yui NARUSE 8 months ago

Nobuyoshi Nakada wrote:

Shouldn't Socket methods raise more descriptive messages?

https://github.com/nobu/ruby/compare/socket-error-message

example domain should use *.invalid
http://tools.ietf.org/html/rfc2606

Also available in: Atom PDF