Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ratelimit/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _wrapped(request, *args, **kw):
increment=True)
request.limited = ratelimited or old_limited
if ratelimited and block:
raise Ratelimited()
raise Ratelimited(group=group, key=key, rate=rate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why stop there? How about allow users to give a message for Ratelimit (helpful if you've got a middleware that can't differentiate views).

return fn(request, *args, **kw)
return _wrapped
return decorator
Expand Down
7 changes: 6 additions & 1 deletion ratelimit/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@


class Ratelimited(PermissionDenied):
pass

def __init__(self, group, key, rate):
super(Ratelimited, self).__init__()
self.group = group
self.key = key
self.rate = rate