Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rate limit headers to base exceptions #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tsalpekar21
Copy link

@tsalpekar21 tsalpekar21 commented Jul 21, 2023

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • 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!

@tsalpekar21 tsalpekar21 requested a review from gumuz as a code owner July 21, 2023 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant