Skip to content

Commit

Permalink
SDK-109 Proper Error Message when results unavailable (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
lordozb authored and chattarajoy committed Jun 19, 2019
1 parent a514198 commit c75e31f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ The SDK is available on `PyPI <https://pypi.python.org/pypi/qds_sdk>`_.

From source
~~~~~~~~~~~
* Download the source code:
* Get the source code:

- Either clone the project: ``git clone [email protected]:qubole/qds-sdk-py.git``
- Either clone the project: ``git clone [email protected]:qubole/qds-sdk-py.git`` and checkout latest release tag from `Releases <https://github.com/qubole/qds-sdk-py/releases>`_.

- Or download one of the releases from https://github.com/qubole/qds-sdk-py/releases

Expand Down
5 changes: 4 additions & 1 deletion qds_sdk/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ def _handle_error(response):
elif code == 422:
sys.stderr.write(response.text + "\n")
raise ResourceInvalid(response)
elif code in (449, 502, 503, 504):
elif code in (502, 503, 504):
sys.stderr.write(response.text + "\n")
raise RetryWithDelay(response)
elif code == 449:
sys.stderr.write(response.text + "\n")
raise RetryWithDelay(response, "Data requested is unavailable. Retrying ...")
elif 401 <= code < 500:
sys.stderr.write(response.text + "\n")
raise ClientError(response)
Expand Down
5 changes: 3 additions & 2 deletions qds_sdk/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ def __init__(self, message, usage):
class Error(Exception):
"""A general error derived from Exception."""

def __init__(self, request):
Exception.__init__(self, request.text)
def __init__(self, request, message = ""):
response = message if message else request.text
Exception.__init__(self, response)
self.request = request


Expand Down

0 comments on commit c75e31f

Please sign in to comment.