Browse Source

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
Wenzhi Yu 3 years ago
parent
commit
848d5312ff
1 changed files with 0 additions and 25 deletions
  1. 0
    25
      openstackclient/common/exceptions.py

+ 0
- 25
openstackclient/common/exceptions.py View File

@@ -108,28 +108,3 @@ _code_map = dict((c.http_status, c) for c in [
108 108
     OverLimit,
109 109
     HTTPNotImplemented
110 110
 ])
111
-
112
-
113
-def from_response(response, body):
114
-    """Return an instance of a ClientException based on an httplib2 response.
115
-
116
-    Usage::
117
-
118
-        resp, body = http.request(...)
119
-        if resp.status != 200:
120
-            raise exception_from_response(resp, body)
121
-    """
122
-    cls = _code_map.get(response.status, ClientException)
123
-    if body:
124
-        if hasattr(body, 'keys'):
125
-            error = body[list(body.keys())[0]]
126
-            message = error.get('message')
127
-            details = error.get('details')
128
-        else:
129
-            # If we didn't get back a properly formed error message we
130
-            # probably couldn't communicate with Keystone at all.
131
-            message = "Unable to communicate with image service: %s." % body
132
-            details = None
133
-        return cls(code=response.status, message=message, details=details)
134
-    else:
135
-        return cls(code=response.status)

Loading…
Cancel
Save