Remove unused method 'from_response'
'openstackclient.common.exceptions.from_response' method is never called in openstackclient code base, so we should remove it. Change-Id: I04254a4e66863942e6c273d77bbd66ce2ce7804c Related-Bug: #1559072
This commit is contained in:
parent
62a6a497bd
commit
848d5312ff
@ -108,28 +108,3 @@ _code_map = dict((c.http_status, c) for c in [
|
|||||||
OverLimit,
|
OverLimit,
|
||||||
HTTPNotImplemented
|
HTTPNotImplemented
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
def from_response(response, body):
|
|
||||||
"""Return an instance of a ClientException based on an httplib2 response.
|
|
||||||
|
|
||||||
Usage::
|
|
||||||
|
|
||||||
resp, body = http.request(...)
|
|
||||||
if resp.status != 200:
|
|
||||||
raise exception_from_response(resp, body)
|
|
||||||
"""
|
|
||||||
cls = _code_map.get(response.status, ClientException)
|
|
||||||
if body:
|
|
||||||
if hasattr(body, 'keys'):
|
|
||||||
error = body[list(body.keys())[0]]
|
|
||||||
message = error.get('message')
|
|
||||||
details = error.get('details')
|
|
||||||
else:
|
|
||||||
# If we didn't get back a properly formed error message we
|
|
||||||
# probably couldn't communicate with Keystone at all.
|
|
||||||
message = "Unable to communicate with image service: %s." % body
|
|
||||||
details = None
|
|
||||||
return cls(code=response.status, message=message, details=details)
|
|
||||||
else:
|
|
||||||
return cls(code=response.status)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user