From a214d983c2ae115c5c4965808f2bd5912c71e4c3 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Fri, 10 Aug 2012 21:06:44 +0000 Subject: [PATCH] socket errors and timeouts should be CommunicationErrors Also include extra information about socket errors within the exceptions. Change-Id: I9464a484460d40be5727e18ca6f057df9076766e --- glanceclient/common/http.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index 6aa8f9f..e18bdf8 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -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)