Merge "Remove unused method 'from_response'"

This commit is contained in:
Jenkins 2016-03-29 16:33:04 +00:00 committed by Gerrit Code Review
commit 9e7f0cf1a5

View File

@ -108,28 +108,3 @@ _code_map = dict((c.http_status, c) for c in [
OverLimit,
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)