From e90918f630cee263fcddba5eb8d0e0f3d7e84984 Mon Sep 17 00:00:00 2001 From: Aaditya Sharma Date: Mon, 10 Jun 2019 14:27:48 +0530 Subject: [PATCH] Added new case for 449 --- qds_sdk/connection.py | 7 ++++++- qds_sdk/exception.py | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/qds_sdk/connection.py b/qds_sdk/connection.py index ede6c412..48fd10e4 100644 --- a/qds_sdk/connection.py +++ b/qds_sdk/connection.py @@ -152,9 +152,14 @@ 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: + message = "Data requested is unavailable. Retrying ..." + sys.stderr.write(response.text + "\n") + sys.stderr.write(message + "\n") + raise RetryWithDelay(response, message) 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..cc802725 100644 --- a/qds_sdk/exception.py +++ b/qds_sdk/exception.py @@ -11,8 +11,11 @@ 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 = request.text + if message: + response = message + Exception.__init__(self, response) self.request = request