domain.errors.rate_limit_error¶
src.domain.errors.rate_limit_error
¶
Rate Limit error types.
Used when rate limiting operations fail (Redis errors, Lua script failures, etc.). Domain-specific error for Rate Limit system (F1.2).
Usage
from src.domain.errors import RateLimitError from src.core.enums import ErrorCode from src.core.result import Failure
return Failure(RateLimitError( code=ErrorCode.RATE_LIMIT_CHECK_FAILED, message="Failed to check rate limit: Redis connection lost" ))
Classes¶
RateLimitError
dataclass
¶
Bases: DomainError
Rate limit system failure.
Used when rate limiting operations fail (Redis connection loss, Lua script errors, invalid configuration, etc.).
Note that rate limit DENIED is NOT an error - it's a successful operation that returns allowed=False. This error class is for actual system failures.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
ErrorCode
|
ErrorCode enum (RATE_LIMIT_CHECK_FAILED, etc.). |
message |
str
|
Human-readable message. |
details |
dict[str, str] | None
|
Additional context (endpoint, identifier, etc.). |
Design
Rate limit follows fail-open design. On errors, implementations should return Success(allowed=True) rather than Failure with this error type. This error type is primarily for: - Configuration errors (rule not found) - Reset operation failures (admin needs to know if reset worked) - Severe errors that prevent any reasonable default