-
Notifications
You must be signed in to change notification settings - Fork 647
Open
Description
This is a snippet taken from send_request function which resides under binance_common/utils.py. Error codes from api aren't passed to the raised exception. Only verbal explanations are passed and since verbal explanations are subject to change, writing control flows against them can cause issues for running trading bots or algorithms. I suggest that error_code field is added to each raised error and inside the send_request function, related error_code is taken from the response and passed into these errors.
if status == 400:
raise BadRequestError(error_message=data.get("msg"))
elif status == 401:
raise UnauthorizedError(error_message=data.get("msg"))
elif status == 403:
raise ForbiddenError(error_message=data.get("msg"))
elif status == 404:
raise NotFoundError(error_message=data.get("msg"))
elif status == 418:
raise RateLimitBanError(error_message=data.get("msg"))
elif status == 429:
raise TooManyRequestsError(error_message=data.get("msg"))
elif 500 <= status < 600:
raise ServerError(
error_message=f"Server error: {status}", status_code=status
)
else:
raise ClientError(error_message=data.get("msg"))
helloWorld74323 and riccstef
Metadata
Metadata
Assignees
Labels
No labels