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
pull/42177/head
Kevin Breit 6 years ago committed by Dag Wieers
parent 61d5454737
commit dd31dcab70

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

Loading…
Cancel
Save