socket errors and timeouts should be CommunicationErrors

Also include extra information about socket errors within the exceptions.

Change-Id: I9464a484460d40be5727e18ca6f057df9076766e
This commit is contained in:
Chris Behrens
2012-08-10 21:06:44 +00:00
parent 3997f977fa
commit a214d983c2
+6 -6
View File
@@ -134,13 +134,13 @@ class HTTPClient(object):
try:
conn.request(method, url, **kwargs)
except (socket.error, socket.gaierror):
raise exc.InvalidEndpoint()
try:
resp = conn.getresponse()
except (socket.error, socket.timeout):
raise exc.CommunicationError()
except socket.gaierror as e:
message = "Error finding address for %(url)s: %(e)s" % locals()
raise exc.InvalidEndpoint(message=message)
except (socket.error, socket.timeout) as e:
message = "Error communicating with %(url)s: %(e)s" % locals()
raise exc.CommunicationError(message=message)
body_iter = ResponseBodyIterator(resp)