GitHub user Kami opened a pull request:
https://github.com/apache/libcloud/pull/711
Throw a more user-friendly exception on "No address associated with
hostname" error
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:
```python
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:
```python
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)?
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Kami/libcloud
connection_error_more_friendly_message
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/libcloud/pull/711.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #711
----
commit 3fb45e2ac74b97fa1cee391573f62529c136c68e
Author: Tomaz Muraus <[email protected]>
Date: 2016-02-23T09:52:57Z
Throw a more user-friendly error on "No address associated with hostname"
exception.
This could simply indicate Connection.host attribute being set to an invalid
value.
commit 8cdde92d759f6185fe9b6fbae1d740563542d32f
Author: Tomaz Muraus <[email protected]>
Date: 2016-02-23T09:54:33Z
Update changelog.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---