diff options
| author | Jason Dunsmore <jasondunsmore@gmail.com> | 2015-10-15 12:00:39 -0500 |
|---|---|---|
| committer | Jason Dunsmore <jasondunsmore@gmail.com> | 2015-10-22 14:34:23 -0500 |
| commit | 2961e82bfa6e375ac3c17933fac532ed316ac976 (patch) | |
| tree | 605b23fcc46452a31bfc2e35583b073d98e80aff /novaclient/client.py | |
| parent | 03f1f67ccde6f495e264da08f0bb7d707cf3ff66 (diff) | |
| download | python-novaclient-2961e82bfa6e375ac3c17933fac532ed316ac976.tar.gz | |
Do not expose exceptions from requests library
Novaclient expects the requests library to always be able to get a
response back and doesn't handle other cases where it might raise
an exception even before the request is completed (e.g.
ConnectionError).
These exceptions should be captured and properly converted to some
native novaclient exception.
Change-Id: Iec7247b715c38c29910b30e76413cead4e951a37
Co-Authored-By: Kuo-tung Kao <jelly.k@inwinstack.com>
Closes-Bug: #1406586
Diffstat (limited to 'novaclient/client.py')
| -rw-r--r-- | novaclient/client.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/novaclient/client.py b/novaclient/client.py index 399d98e2..5787a2c2 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -84,13 +84,12 @@ class SessionClient(adapter.LegacyJsonAdapter): # NOTE(jamielennox): The standard call raises errors from # keystoneclient, where we need to raise the novaclient errors. raise_exc = kwargs.pop('raise_exc', True) - with utils.record_time(self.times, self.timings, method, url): - resp, body = super(SessionClient, self).request(url, - method, - raise_exc=False, - **kwargs) - if raise_exc and resp.status_code >= 400: - raise exceptions.from_response(resp, body, url, method) + with utils.converted_exceptions(): + with utils.record_time(self.times, self.timings, method, url): + resp, body = super(SessionClient, self).request( + url, method, raise_exc=False, **kwargs) + if raise_exc and resp.status_code >= 400: + raise exceptions.from_response(resp, body, url, method) return resp, body @@ -360,10 +359,11 @@ class HTTPClient(object): if session: request_func = session.request - resp = request_func( - method, - url, - **kwargs) + with utils.converted_exceptions(): + resp = request_func( + method, + url, + **kwargs) self.http_log_resp(resp) |
