Instagram/python-instagram — pull request #68 by johnboiles (2014-05-02 19:48:43+00:00)
Title: Adding an optional status_code to InstagramClientError

Fairly regularly, the Instagram API returns HTTP 504s and/or 502s. This raises an `InstagramClientError` with the message “Unable to parse response, not valid JSON.” To be able to handle only 502 and 504 errors, `InstagramClientError` needs to pass along the `status_code` of the response.

For the future, I think the cleaner way to handle these errors would be to use an `InstagramAPIError` instead of an `InstagramClientError` for handling invalid JSON. bind.py:99 would then look like this:

raise InstagramAPIError(response['status'], "Invalid JSON", "Unable to parse response, not valid JSON.")

However, this has the potential to break compatibility with old versions if people are expecting an `InstagramClientError` for invalid JSON. This provides an interim solution without breaking compatibility.