"""errors and exceptions."""from__future__importannotationsfromflask.wrappersimportResponsefromwerkzeugimportexceptionsfrom.wrappersimportLimit
[docs]classRateLimitExceeded(exceptions.TooManyRequests):"""Exception raised when a rate limit is hit."""def__init__(self,limit:Limit,response:Response|None=None)->None:""" :param limit: The actual rate limit that was hit. Used to construct the default response message :param response: Optional pre constructed response. If provided it will be rendered by flask instead of the default error response of :class:`~werkzeug.exceptions.HTTPException` """self.limit=limitself.response=responseiflimit.error_message:description=(limit.error_messageifnotcallable(limit.error_message)elselimit.error_message())else:description=str(limit.limit)super().__init__(description=description,response=response)