From 472684366f957080d3c73af8093cc85c49c3cb46 Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Thu, 24 Mar 2016 16:26:17 -0400 Subject: [PATCH 1/4] HTTPError.message is not a thing --- sprockets/clients/dynamodb/__init__.py | 2 +- sprockets/clients/dynamodb/connector.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sprockets/clients/dynamodb/__init__.py b/sprockets/clients/dynamodb/__init__.py index 0eabb92..30a10bd 100644 --- a/sprockets/clients/dynamodb/__init__.py +++ b/sprockets/clients/dynamodb/__init__.py @@ -4,7 +4,7 @@ except ImportError as error: def DynamoDB(*args, **kwargs): raise error -version_info = (0, 2, 0) +version_info = (0, 2, 1) __version__ = '.'.join(str(v) for v in version_info) # Response constants diff --git a/sprockets/clients/dynamodb/connector.py b/sprockets/clients/dynamodb/connector.py index a6e698a..43cc6ca 100644 --- a/sprockets/clients/dynamodb/connector.py +++ b/sprockets/clients/dynamodb/connector.py @@ -104,8 +104,9 @@ class DynamoDB(object): if http_err.code == 599: future.set_exception(exceptions.TimeoutException()) else: + future.set_exception( - exceptions.RequestException(http_err.message)) + exceptions.RequestException(http_err.response.body)) except Exception as exception: future.set_exception(exception) else: @@ -126,7 +127,8 @@ class DynamoDB(object): if err.code == 599: future.set_exception(exceptions.TimeoutException()) else: - future.set_exception(exceptions.RequestException(err.message)) + future.set_exception( + exceptions.RequestException(err.response.body)) else: ioloop.IOLoop.current().add_future(aws_response, handle_response) return future From e4928b1cff397c1d28460b33ea89f0893755bb8b Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Thu, 24 Mar 2016 16:36:14 -0400 Subject: [PATCH 2/4] response can be None. Yay. --- sprockets/clients/dynamodb/connector.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sprockets/clients/dynamodb/connector.py b/sprockets/clients/dynamodb/connector.py index 43cc6ca..1bdf430 100644 --- a/sprockets/clients/dynamodb/connector.py +++ b/sprockets/clients/dynamodb/connector.py @@ -104,9 +104,10 @@ class DynamoDB(object): if http_err.code == 599: future.set_exception(exceptions.TimeoutException()) else: - - future.set_exception( - exceptions.RequestException(http_err.response.body)) + response_reason = err.code + if err.response and hasattr(err.response, 'body'): + response_reason = err.response.body + future.set_exception(response_reason) except Exception as exception: future.set_exception(exception) else: @@ -127,8 +128,10 @@ class DynamoDB(object): if err.code == 599: future.set_exception(exceptions.TimeoutException()) else: - future.set_exception( - exceptions.RequestException(err.response.body)) + reason = err.code + if err.response and hasattr(err.response, 'body'): + reason = err.response.body + future.set_exception(reason) else: ioloop.IOLoop.current().add_future(aws_response, handle_response) return future From 69888b6b7100d42f85df2430a04048dde054f261 Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Thu, 24 Mar 2016 16:36:49 -0400 Subject: [PATCH 3/4] Wrong exception --- sprockets/clients/dynamodb/connector.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sprockets/clients/dynamodb/connector.py b/sprockets/clients/dynamodb/connector.py index 1bdf430..89a4393 100644 --- a/sprockets/clients/dynamodb/connector.py +++ b/sprockets/clients/dynamodb/connector.py @@ -104,9 +104,10 @@ class DynamoDB(object): if http_err.code == 599: future.set_exception(exceptions.TimeoutException()) else: - response_reason = err.code - if err.response and hasattr(err.response, 'body'): - response_reason = err.response.body + response_reason = http_err.code + if http_err.response and \ + hasattr(http_err.response, 'body'): + response_reason = http_err.response.body future.set_exception(response_reason) except Exception as exception: future.set_exception(exception) From 5219e025e9a6d8b9401f17e1de7e042f47e651a8 Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Thu, 24 Mar 2016 16:42:29 -0400 Subject: [PATCH 4/4] Actually raise an exception --- sprockets/clients/dynamodb/connector.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sprockets/clients/dynamodb/connector.py b/sprockets/clients/dynamodb/connector.py index 89a4393..5a0882b 100644 --- a/sprockets/clients/dynamodb/connector.py +++ b/sprockets/clients/dynamodb/connector.py @@ -104,11 +104,12 @@ class DynamoDB(object): if http_err.code == 599: future.set_exception(exceptions.TimeoutException()) else: - response_reason = http_err.code + response_reason = str(http_err.code) if http_err.response and \ hasattr(http_err.response, 'body'): response_reason = http_err.response.body - future.set_exception(response_reason) + future.set_exception( + exceptions.RequestException(response_reason)) except Exception as exception: future.set_exception(exception) else: @@ -129,10 +130,11 @@ class DynamoDB(object): if err.code == 599: future.set_exception(exceptions.TimeoutException()) else: - reason = err.code + reason = str(err.code) if err.response and hasattr(err.response, 'body'): reason = err.response.body - future.set_exception(reason) + future.set_exception(exceptions.RequestException(reason)) + else: ioloop.IOLoop.current().add_future(aws_response, handle_response) return future