Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a more user-friendly exception on "No address associated with hostname" error #711

Merged
merged 3 commits into from
Feb 23, 2016

Conversation

Kami
Copy link
Member

@Kami Kami commented Feb 23, 2016

Usually this issue represents a bug in the driver (host connection class attribute being set to an incorrect value), but the original exception is kinda cryptic so it's hard for the users to figure out what is going on.

Before:

Traceback (most recent call last):
  File "example.py", line 5, in <module>
    print driver.list_zones()
  File "/home/kami/w/lc/libcloud/libcloud/dns/drivers/godaddy.py", line 146, in list_zones
    '/v1/domains/').object
  File "/home/kami/w/lc/libcloud/libcloud/common/base.py", line 827, in request
    headers=headers)
  File "/usr/lib64/python2.7/httplib.py", line 1053, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.7/httplib.py", line 1093, in _send_request
    self.endheaders(body)
  File "/usr/lib64/python2.7/httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 893, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.7/httplib.py", line 855, in send
    self.connect()
  File "/home/kami/w/lc/libcloud/libcloud/httplib_ssl.py", line 284, in connect
    self.timeout)
  File "/usr/lib64/python2.7/socket.py", line 557, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -5] No address associated with hostname

After:

Traceback (most recent call last):
  File "example.py", line 5, in <module>
    print driver.list_zones()
  File "/home/kami/w/lc/libcloud/libcloud/dns/drivers/godaddy.py", line 146, in list_zones
    '/v1/domains/').object
  File "/home/kami/w/lc/libcloud/libcloud/common/base.py", line 842, in request
    raise socket.gaierror(msg)
socket.gaierror: [Errno -5] No address associated with hostname. Perhaphs "host" Connection class attribute (GoDaddyDNSConnection.connection) is set to an invalid, non-hostname value (http://www.google.com)?

…ame"

exception.

This could simply indicate Connection.host attribute being set to an invalid
value.
@asfgit asfgit merged commit 8c52008 into apache:trunk Feb 23, 2016
# "host" Connection class attribute is set to an incorrect
# value
class_name = self.__class__.__name__
msg = ('%s. Perhaphs "host" Connection class attribute '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's too late now, but you meant 'perhaps'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps :P

Joking aside, good catch, will push a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants