Skip to content

Commit 1ec41a0

Browse files
authored
Update errors.py
1 parent 5f49450 commit 1ec41a0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎app/controllers/errors.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,17 @@ class PayloadTooLarge(DomainError):
5959
"""Upload exceeds the configured limit (413)."""
6060

6161
status_code = 413
62+
63+
64+
class TooManyRequests(DomainError):
65+
"""Rate limit exceeded (429).
66+
67+
``retry_after`` (seconds) is surfaced as a ``Retry-After`` header by
68+
the app's error handler.
69+
"""
70+
71+
status_code = 429
72+
73+
def __init__(self, detail: str, retry_after: int = 1) -> None:
74+
super().__init__(detail)
75+
self.retry_after = retry_after

0 commit comments

Comments
 (0)