From dca30fbb936dfaca7f5f10ab34a67e6460b3b235 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Tue, 2 Apr 2013 21:25:30 -0700 Subject: [PATCH] Convert requests.ConnectionError to ClientException Fixes bug 1163678 Change-Id: I16201eda29a56e3c1e6008989260425ddc124ea6 --- keystoneclient/client.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/keystoneclient/client.py b/keystoneclient/client.py index fb5c6dbc6..b9d4bc7cd 100644 --- a/keystoneclient/client.py +++ b/keystoneclient/client.py @@ -351,11 +351,16 @@ class HTTPClient(object): request_kwargs.setdefault('timeout', self.timeout) self.http_log_req((url, method,), request_kwargs) - resp = requests.request( - method, - url, - verify=self.verify_cert, - **request_kwargs) + + try: + resp = requests.request( + method, + url, + verify=self.verify_cert, + **request_kwargs) + except requests.ConnectionError: + msg = 'Unable to establish connection to %s' % url + raise exceptions.ClientException(msg) self.http_log_resp(resp)