#[derive(Debug, thiserror::Error)]
pub enum VerifexError {
#[error("authentication failed: {message}")]
Auth {
message: String,
request_id: String,
},
#[error("rate limit exceeded: {message}")]
RateLimit {
message: String,
retry_after: u64,
request_id: String,
},
#[error("quota exceeded: {message}")]
QuotaExceeded {
message: String,
request_id: String,
},
#[error("API error [{code}]: {message}")]
Api {
message: String,
code: String,
status: u16,
request_id: String,
},
#[error("request failed: {0}")]
Request(#[from] reqwest::Error),
}
impl VerifexError {
pub fn is_auth(&self) -> bool {
matches!(self, Self::Auth { .. })
}
pub fn is_rate_limit(&self) -> bool {
matches!(self, Self::RateLimit { .. })
}
pub fn is_quota_exceeded(&self) -> bool {
matches!(self, Self::QuotaExceeded { .. })
}
}