use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ProxyError {
#[error("proxy pool is exhausted")]
PoolExhausted,
#[error("all proxies are unhealthy")]
AllProxiesUnhealthy,
#[error("invalid proxy URL `{url}`: {reason}")]
InvalidProxyUrl {
url: String,
reason: String,
},
#[error("health check failed for proxy `{proxy}`: {message}")]
HealthCheckFailed {
proxy: String,
message: String,
},
#[error("circuit breaker is open for proxy `{proxy}`")]
CircuitOpen {
proxy: String,
},
#[error("storage error: {0}")]
StorageError(String),
#[error("configuration error: {0}")]
ConfigError(String),
#[error("proxy fetch failed from `{origin}`: {message}")]
FetchFailed {
origin: String,
message: String,
},
#[error("no proxy satisfies the requested capabilities")]
NoCompatibleProxy,
}
pub type ProxyResult<T> = Result<T, ProxyError>;