use thiserror::Error;
pub type CinemaResult<T> = std::result::Result<T, CinemaError>;
#[derive(Error, Debug)]
pub enum CinemaError {
#[error("Failed to lock {0}")]
Lock(&'static str),
#[error("Failed to find available port")]
FindPort,
#[error("Failed to start a TCP listener at {1}")]
BindTcp(#[source] std::io::Error, String),
#[error("Failed to lookup host {1}")]
LookupHost(#[source] std::io::Error, String),
#[error("Failed to connect to a TCP stream at {1}")]
ConnectTcpStream(#[source] std::io::Error, String),
#[error("Failed to set up TLS connection")]
TlsConnection(#[from] tokio_native_tls::native_tls::Error),
#[error("Failed to handshake with {1}")]
Handshake(#[source] hyper::Error, String),
#[error("Failed to read body from original request")]
ReadOriginalBody(#[source] hyper::Error),
#[error("Failed to send forwarding request")]
ForwardRequest(#[source] hyper::Error),
#[error("Failed to forward body")]
ForwardBody(#[source] hyper::http::Error),
#[error("Failed to serialize {1}")]
Serialize(#[source] toml::ser::Error, &'static str),
#[error("Failed to restore response body")]
RestoreResponseBody(#[source] hyper::http::Error),
}