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

Add handling for backend error #75

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Bharat23
Copy link

@Bharat23 Bharat23 commented Jun 6, 2024

Changes

  • Add a new exception folder to store all the custom exception classes
  • update core.py to catch BaseBackendException
  • Add new argument on_backend_error to RateLimitMiddleware , defaults to _on_backend_error and can be modified by enduser by passing their custom function
  • Update RedisBackend to catch ConnectionError raised by redis and raise custom exception instead
  • Add 2 test cases for backend error both with and without the use of custom _on_backend_error function.

@Bharat23
Copy link
Author

Bharat23 commented Jul 6, 2024

@abersheeran Can I get a review for this PR? Thanks

ratelimit/exceptions/__init__.py Outdated Show resolved Hide resolved
ratelimit/core.py Outdated Show resolved Hide resolved
assert response.text == "custom 503 page"


def yourself_503(retry_after: int):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type hint is incorrect.

@abersheeran
Copy link
Owner

Please update README.md.

@Bharat23
Copy link
Author

Bharat23 commented Aug 3, 2024

Please update README.md.

Updated to the best of my understanding. Please let me know if any additional information needs to be added.

@Bharat23 Bharat23 requested a review from abersheeran October 13, 2024 17:29
@abersheeran
Copy link
Owner

Can the code be modified so that it passes CI tests?

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.

2 participants