mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Handle the case where HTTPError.info() returns an object that aren't (#22894)
dict-like enough (can't be used with **). This should give a better error message for #22872
This commit is contained in:
parent
6cea89299a
commit
29f623571e
1 changed files with 10 additions and 2 deletions
|
@ -1009,8 +1009,16 @@ def fetch_url(module, url, data=None, headers=None, method=None,
|
||||||
body = e.read()
|
body = e.read()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
body = ''
|
body = ''
|
||||||
info.update(dict(msg=str(e), body=body, **e.info()))
|
|
||||||
info['status'] = e.code
|
# Try to add exception info to the output but don't fail if we can't
|
||||||
|
exc_info = e.info()
|
||||||
|
try:
|
||||||
|
info.update(dict(**e.info()))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
info.update({'msg': str(e), 'body': body, 'status': e.code})
|
||||||
|
|
||||||
except urllib_error.URLError:
|
except urllib_error.URLError:
|
||||||
e = get_exception()
|
e = get_exception()
|
||||||
code = int(getattr(e, 'code', -1))
|
code = int(getattr(e, 'code', -1))
|
||||||
|
|
Loading…
Reference in a new issue