use std::net::SocketAddr;
use crate::config::ConfigError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum PingoraError {
#[error(transparent)]
Config(#[from] ConfigError),
#[error("cannot bind the proxy listener on {addr}: {source}")]
Bind {
addr: SocketAddr,
source: std::io::Error,
},
#[error("route `{route}`: cannot resolve upstream \"{upstream}\": {reason}")]
Resolve {
route: String,
upstream: String,
reason: String,
},
#[error("cannot resolve the Autumn app address \"{0}\" for `fallback = \"app\"`")]
AppAddress(String),
#[error(
"`fallback = \"app\"` needs a plain HTTP app. `[server.tls]` is set. Put a TLS terminator in front of the proxy, or set `fallback = \"none\"`"
)]
FallbackTls,
#[error(
"the proxy address is the Autumn app address {0}. With `fallback = \"app\"`, requests would go in a loop. Set a different `bind`"
)]
FallbackLoop(SocketAddr),
#[error("the proxy started or stopped before; it can start one time only")]
AlreadyStarted,
}