Remove redundant statement and refactor
1. Remove redundant pass-statement in except-block. 2. Define "body = None" before if-block to get rid of body-statement both in except-block and else-case. 3. Acknowledge error occurred instead of silently squashing it. Change-Id: I31e17827b40e7a15d88ecacf1fdb2abbbe2da5c0 Signed-off-by: Lin Yang <lin.a.yang@intel.com>
This commit is contained in:
parent
f860668d71
commit
c23586b73f
@ -238,14 +238,12 @@ class HTTPClient(object):
|
||||
**kwargs)
|
||||
self.http_log_resp(resp)
|
||||
|
||||
body = None
|
||||
if resp.text:
|
||||
try:
|
||||
body = json.loads(resp.text)
|
||||
except ValueError:
|
||||
pass
|
||||
body = None
|
||||
else:
|
||||
body = None
|
||||
except ValueError as e:
|
||||
self._logger.debug("Load http response text error: %s", e)
|
||||
|
||||
if resp.status_code >= 400:
|
||||
raise exceptions.from_response(resp, body)
|
||||
|
Loading…
x
Reference in New Issue
Block a user