Closed stevenday closed 11 years ago
The change to using urllib2 for all requests means that an HTTPError
will be raised in the above situations.
However this mean that the handling for empty responses (which the API poorly implements using 404 responses) will instead need to change to catch the exception, test the code and act appropriately.
Sample error report now produced:
Traceback (most recent call last):
.... snip ....
File "/data/vhost/citizenconnect.test.mysociety.org/citizenconnect/reviews_display/reviews_api.py", line 74, in fetch_from_api
response = self.api.send_api_request(url)
File "/data/vhost/citizenconnect.test.mysociety.org/citizenconnect/organisations/choices_api.py", line 46, in send_api_request
.... snip ....
File "/usr/lib/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
Currently we're getting errors like:
Which I believe is due to the code trying to parse the NHS choices error page (for whatever reason it has arrived at that). This page returns a 503 status code, so we shouldn't even be trying to process it, rather just raising an error about it returning a 503.