We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 68aef10 commit cd153d9Copy full SHA for cd153d9
src/paste/main.py
@@ -54,8 +54,17 @@
54
)
55
app.state.limiter = limiter
56
57
-async def rate_limit_exceeded_handler(request: Request, exc: Exception) -> Union[Response, Awaitable[Response]]:
58
- return _rate_limit_exceeded_handler(request, exc)
+
+def rate_limit_exceeded_handler(request: Request, exc: Exception) -> Union[Response, Awaitable[Response]]:
59
+ if isinstance(exc, RateLimitExceeded):
60
+ return Response(
61
+ content="Rate limit exceeded",
62
+ status_code=429
63
+ )
64
65
+ content="An error occurred",
66
+ status_code=500
67
68
69
app.add_exception_handler(RateLimitExceeded, rate_limit_exceeded_handler)
70
0 commit comments