stream-chat-python
stream-chat-python copied to clipboard
feat: add rate limit headers to base exceptions
Submit a pull request
CLA
- [x] I have signed the Stream CLA (required).
- [x] The code changes follow best practices
- [x] Code changes are tested (add some information if not applicable)
Description of the pull request
When I was implementing some bulk Stream chat operations, I ran into some rate limits and was going to implement a rate limit reset handler. Upon building that, I realized the StreamAPIException that's thrown when a developer gets rate limited doesn't contain details about the rate limit, even though the StreamResponse contains a very nice RateLimitInfo object.
It'd be great to have the rate limit details exist in the StreamAPIException that gets thrown when we actually hit the error. That way, the developer can get the details (like when the rate limit resets), right in the except handler and wait accordingly.
Everything should be backwards-compatible. The design choice was inspired by StreamResponse also inheriting from dict.
PS, I've never contributed to a public repo before so lmk if I've missed anything!