Hi there,
I wrote modules to manage Dimension Data Cloud Platform. https://github.com/job-so/ansible.CaaS
These modules are working well, and already tested by different users for different use cases.
Before proposing a PR to ansible-modules-extras, i am cleaning the documentation and i am checking the community recommendations.
It includes the replacement of url2lib by fetch_url
I am facing the following issue : i need to handle the 400-Bad request HTTP error of an underlying API.
This API is providing detailed information about the error in the web page content.
[Quote from https://docs.python.org/2/library/urllib2.html]
- *exception* `urllib2.``HTTPError`
-
Though being an exception (a subclass of
URLError
), anHTTPError
can also function as a non-exceptional file-like return value (the same thing thaturlopen()
returns). This is useful when handling exotic HTTP errors, such as requests for authentication.
So i need to access to e.read() method.
845: except urllib2.HTTPError, e:
+++: r = e # <=== or something smarter
846: info.update(dict(msg=str(e), status=e.code, **e.info()))
Do you think we can fix the code in this way ? I may do the fix/PR if needed.
Thank you
Olivier.