diff options
| author | Akira KAMIO <akamio@yahoo-corp.jp> | 2016-12-06 14:10:38 +0900 |
|---|---|---|
| committer | Simon Leinen <simon.leinen@gmail.com> | 2017-05-03 16:12:24 +0000 |
| commit | b20d9fd6563c1ef295e8a260742f2b3e0b8ee327 (patch) | |
| tree | d6d14fbc5a32ccff4493f71c14bdd3318d670235 | |
| parent | e22222a428c7d72efe577c76f586bf4a4088e1f8 (diff) | |
| download | python-cinderclient-stable/newton.tar.gz | |
Handle error response for webob>=1.6.0newton-eolstable/newton
WebOb change https://github.com/Pylons/webob/pull/230 changed
the way in which the error response body is formatted such that
it's no longer a nested dict. So we have to handle both the
old convention of an error message key to the response body error
dict and the new way with just the error body dict.
This was reported upstream:
https://github.com/Pylons/webob/issues/235
But given this was apparently implemented as a long-overdue change
in WebOb the behavior is not likely to change.Handle error response for
webob>=1.6.0
Change-Id: I7d589415aa024588faf77c8234ac026110f6c3cd
Closes-Bug: #1559072
(cherry picked from commit 19befa69651a41534c7d25b1a0d3a0cd407afb44)
| -rw-r--r-- | cinderclient/exceptions.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cinderclient/exceptions.py b/cinderclient/exceptions.py index 23b31b1..43ae5a4 100644 --- a/cinderclient/exceptions.py +++ b/cinderclient/exceptions.py @@ -242,9 +242,14 @@ def from_response(response, body): message = "n/a" details = "n/a" if hasattr(body, 'keys'): - error = body[list(body)[0]] - message = error.get('message', message) - details = error.get('details', details) + # Only in webob>=1.6.0 + if 'message' in body: + message = body.get('message') + details = body.get('details') + else: + error = body[list(body)[0]] + message = error.get('message', message) + details = error.get('details', details) return cls(code=response.status_code, message=message, details=details, request_id=request_id, response=response) else: |
