1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Meraki module utility request() has improved error reporting (#39838)

* request() has improved error reporting
- 5xx errors show same as before
- 3xx and 4xx errors show error body

* Print body for errors greater than 300, but less than 500

* Remove trailing whitespace
This commit is contained in:
Kevin Breit 2018-07-02 03:42:50 -05:00 committed by Dag Wieers
parent 61d5454737
commit dd31dcab70

View file

@ -259,8 +259,11 @@ class MerakiModule(object):
self.response = info['msg']
self.status = info['status']
if self.status >= 300:
if self.status >= 500:
self.fail_json(msg='Request failed for {url}: {status} - {msg}'.format(**info))
elif self.status >= 300:
self.fail_json(msg='Request failed for {url}: {status} - {msg}'.format(**info),
body=json.loads(to_native(info['body'])))
try:
return json.loads(to_native(resp.read()))
except: