use std::time::Duration;
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
pub enum RateLimitError {
#[error("client key unavailable ({0}): {1}")]
Key(String, String),
#[error("rate-limit quota unavailable ({0}): {1}")]
Quota(String, String),
#[error("rate-limit store unavailable ({0}): {1}")]
Store(String, String),
}
impl RateLimitError {
pub fn code(&self) -> &str {
match self {
Self::Key(code, _) | Self::Quota(code, _) | Self::Store(code, _) => code,
}
}
}
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
pub enum ConfigError {
#[error("rate-limit window {0:?} is shorter than the minimum {1:?}")]
WindowTooShort(Duration, Duration),
#[error("empty policy name")]
EmptyPolicyName,
}