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 Jul 31, 2019
1 parent 35fe334 commit 87989ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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 87989ce

Please sign in to comment.