Skip to content

Commit c5429de

Browse files
committed
get_request_result: add dedicated RequestException()
1 parent adff0ee commit c5429de

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pyetrade/order.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def to_decimal_str(price: float, round_down: bool) -> str:
3232
return spstr
3333

3434

35+
class RequestException(Exception):
36+
""":description: Exception raised when request to Etrade API returns an error"""
37+
pass
38+
39+
3540
def get_request_result(req: OAuth1Session.request, resp_format: str = "xml") -> dict:
3641
LOGGER.debug(req.text)
3742

@@ -47,7 +52,7 @@ def get_request_result(req: OAuth1Session.request, resp_format: str = "xml") ->
4752
req_output = xmltodict.parse(req.text)
4853

4954
if "Error" in req_output.keys():
50-
raise Exception(
55+
raise RequestException(
5156
f'Etrade API Error - Code: {req_output["Error"]["code"]}, Msg: {req_output["Error"]["message"]}'
5257
)
5358

0 commit comments

Comments
 (0)