Skip to content

Commit b3c9048

Browse files
author
Pegasus
committed
Add exception: code 429 exceeding query limit
1 parent b42dd54 commit b3c9048

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

td/client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ def __init__(self, message):
3636
self.message = message
3737
super().__init__(self.message)
3838

39+
class ExdLmtError(Exception):
40+
"""Raise exception when exceeding query limit of the server.
41+
42+
Args:
43+
Exception (Exception): The base python exception class
44+
"""
45+
def __init__(self, message):
46+
"""Print out message for this exception.
47+
48+
Args:
49+
message (str): Pass in the message returned by the server.
50+
"""
51+
self.message = message
52+
super().__init__(self.message)
53+
3954
class TDClient():
4055

4156
"""TD Ameritrade API Client Class.
@@ -585,6 +600,8 @@ def _make_request(self, method: str, endpoint: str, mode: str = None, params: di
585600

586601
if response.status_code == 401:
587602
raise TknExpError(message=response.text)
603+
elif response.status_code == 429:
604+
raise ExdLmtError(message=response.text)
588605

589606
def _validate_arguments(self, endpoint: str, parameter_name: str, parameter_argument: List[str]) -> bool:
590607
"""Validates arguments for an API call.

0 commit comments

Comments
 (0)