Skip to main content

subscription_proxy_pool/
error.rs

1/// Errors do not include subscription contents or credential-bearing URLs.
2#[derive(Debug, thiserror::Error)]
3#[non_exhaustive]
4pub enum Error {
5    /// Invalid configuration or proxy endpoint.
6    #[error("invalid configuration: {0}")]
7    Config(&'static str),
8    /// Subscription retrieval or parsing failed.
9    #[error("subscription error: {0}")]
10    Subscription(&'static str),
11    /// Cache validation or asynchronous cache work failed.
12    #[error("cache error: {0}")]
13    Cache(&'static str),
14    /// A network failure with its URL removed.
15    #[error("network error: {0}")]
16    Transport(#[source] reqwest::Error),
17    /// Local file access failed.
18    #[error("file access error: {0}")]
19    Io(#[from] std::io::Error),
20    /// No node is currently eligible; requests are never silently sent directly.
21    #[error("no eligible proxy is available")]
22    NoProxyAvailable,
23    /// Healthy nodes exist, but all have reached their configured concurrency limit.
24    #[error("all eligible proxies are at their in-flight request limit")]
25    PoolSaturated,
26    /// A configured subscription pool could not load any supported nodes.
27    #[error("could not initialize subscriptions: {0:?}")]
28    Initialization(Vec<crate::SourceReport>),
29}
30
31/// Result type used by this crate.
32pub type Result<T> = std::result::Result<T, Error>;
33
34impl From<reqwest::Error> for Error {
35    fn from(error: reqwest::Error) -> Self {
36        Self::Transport(error.without_url())
37    }
38}