Skip to main content

mocra_proxy/
error.rs

1//! Error types for mocra-proxy.
2//!
3//! Independent of the host crate — as a standalone-usable library, proxy has its own
4//! `ProxyError` / `Result`; the host `mocra` folds them into its own error hierarchy at the
5//! boundary via `impl From<ProxyError> for mocra::Error`.
6
7use thiserror::Error;
8
9/// A boxed underlying error source (same shape as the host's `mocra::BoxError`).
10pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;
11
12/// `Result` alias for mocra-proxy.
13pub type Result<T> = std::result::Result<T, ProxyError>;
14
15/// Proxy subsystem errors.
16#[derive(Debug, Error)]
17pub enum ProxyError {
18    #[error("invalid config: {0}")]
19    InvalidConfig(#[source] BoxError),
20    #[error("missing field: {0}")]
21    MissingField(#[source] BoxError),
22    #[error("parse error: {0}")]
23    ParseError(#[source] BoxError),
24    #[error("get proxy error: {0}")]
25    GetProxy(#[source] BoxError),
26    #[error("proxy not found")]
27    ProxyNotFound,
28    #[error("proxy not available: {0}")]
29    ProxyNotAvailable(#[source] BoxError),
30    #[error("proxy already expired")]
31    ProxyExpired,
32    #[error("proxy provider already expired")]
33    ProxyProviderExpired,
34    #[error("proxy connection failed")]
35    ProxyConnectionFailed,
36    #[error("proxy authentication failed")]
37    ProxyAuthenticationFailed,
38}