Skip to content

Commit e0d5f18

Browse files
committed
Fixed issue with message -> code. added rate limit exception and tset
1 parent 85e93c0 commit e0d5f18

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

gdax/exceptions.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def code(self):
2828
return self._code
2929

3030
@message.setter
31-
def message(self, code):
31+
def code(self, code):
3232
self._code = code
3333

3434

@@ -60,6 +60,13 @@ class NotFoundGdaxRequest(GdaxException):
6060
pass
6161

6262

63+
class GdaxRateLimitRequest(GdaxException):
64+
"""
65+
Raised on 429 response from GDAX
66+
"""
67+
pass
68+
69+
6370
class UnknownGdaxClientRequest(GdaxException):
6471
"""
6572
Raised on 4XX responses not tracked

gdax/public_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def _determine_response(self, response):
6666
elif response.status_code == HTTPStatus.NOT_FOUND:
6767
raise exceptions.NotFoundGdaxRequest(message,
6868
HTTPStatus.NOT_FOUND)
69+
elif response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
70+
raise exceptions.GdaxRateLimitRequest(message,
71+
HTTPStatus.TOO_MANY_REQUESTS)
6972
else: # Other 4XX response not yet mapped
7073
raise exceptions.UnknownGdaxClientRequest(message,
7174
response.status_code)

tests/test_error_handling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def client():
1414
(403, gdax.exceptions.ForbiddenGdaxRequest),
1515
(404, gdax.exceptions.NotFoundGdaxRequest),
1616
(422, gdax.exceptions.UnknownGdaxClientRequest),
17+
(429, gdax.exceptions.GdaxRateLimitRequest),
1718
(500, gdax.exceptions.InternalErrorGdaxRequest)])
1819
@patch('requests.get')
1920
def test_gdax_exceptions(mock_request, client, code, exception):

0 commit comments

Comments
 (0)