Skip to main content

asimov_proxy/
error.rs

1// This is free and unencumbered software released into the public domain.
2
3use alloc::string::String;
4
5/// Proxy configuration and initialization failures, without credentials.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    /// Shared endpoint validation or environment/native discovery failed.
9    #[error(transparent)]
10    Proxy(#[from] asimov_http::proxy::Error),
11
12    /// The proxy URL could not be parsed.
13    #[error("invalid proxy URL: {0}")]
14    InvalidProxyUrl(#[from] url::ParseError),
15
16    /// The proxy URL has no host.
17    #[error("proxy URL is missing a host")]
18    MissingProxyHost,
19
20    /// The percent-decoded username is not UTF-8.
21    #[error("proxy username is not valid UTF-8")]
22    InvalidProxyUsername,
23
24    /// The percent-decoded password is not UTF-8.
25    #[error("proxy password is not valid UTF-8")]
26    InvalidProxyPassword,
27
28    /// The selected proxy scheme is not supported by this connector.
29    #[error("unsupported proxy scheme: {0}")]
30    UnsupportedProxyScheme(String),
31
32    /// The upstream API key is empty or whitespace-only.
33    #[error("API key must be set and nonempty")]
34    MissingApiKey,
35
36    /// The upstream API key cannot be used in an HTTP header.
37    #[error("API key contains invalid HTTP header bytes")]
38    InvalidApiKey,
39
40    /// Native TLS trust roots could not be loaded.
41    #[cfg(feature = "std")]
42    #[error("failed to load native TLS roots: {0}")]
43    NativeRoots(#[from] std::io::Error),
44
45    /// The TLS configuration could not be initialized.
46    #[cfg(feature = "std")]
47    #[error("failed to configure TLS: {0}")]
48    Tls(#[from] rustls::Error),
49}