Handle non-JSON return values
This commit is contained in:
parent
0b5fd3a2cf
commit
b7e3210631
|
@ -157,12 +157,14 @@ def remote_config(module, method='GET', config=None, result=None, device=None,
|
|||
|
||||
try:
|
||||
content = resp.read()
|
||||
return json.loads(content)
|
||||
except (AttributeError, json.decoder.JSONDecodeError):
|
||||
except AttributeError:
|
||||
result['content'] = info.pop('body', '')
|
||||
module.fail_json(msg='Error occured while reading response', **result)
|
||||
|
||||
return {} # not reachable but prevents linter complaints
|
||||
try:
|
||||
return json.loads(content)
|
||||
except json.decoder.JSONDecodeError:
|
||||
return {'content': content}
|
||||
|
||||
|
||||
def get_device(module, device=None):
|
||||
|
|
Loading…
Reference in New Issue
Block a user