From 87989ceeca94c90b511c22b2c22898755cdeb814 Mon Sep 17 00:00:00 2001 From: Aaditya Sharma Date: Wed, 19 Jun 2019 15:04:00 +0530 Subject: [PATCH] SDK-109 Proper Error Message when results unavailable (#276) --- qds_sdk/connection.py | 5 ++++- qds_sdk/exception.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/qds_sdk/connection.py b/qds_sdk/connection.py index ede6c412..0398acb5 100644 --- a/qds_sdk/connection.py +++ b/qds_sdk/connection.py @@ -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) diff --git a/qds_sdk/exception.py b/qds_sdk/exception.py index 5e361902..ef06a335 100644 --- a/qds_sdk/exception.py +++ b/qds_sdk/exception.py @@ -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