use std::fmt::Debug;
use crate::service::{HttpService, HttpServiceFactory};
#[derive(Debug, thiserror::Error)]
pub enum HttpError<F>
where
F: HttpServiceFactory,
F::Error: std::error::Error,
<F::Service as HttpService>::Error: std::error::Error,
<<F::Service as HttpService>::ResBody as http_body::Body>::Error: std::error::Error,
{
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("{0}")]
#[cfg(all(feature = "http3", feature = "tls-rustls"))]
NoInitialCipherSuite(#[from] h3_quinn::quinn::crypto::rustls::NoInitialCipherSuite),
#[error("h3 connection error: {0}")]
#[cfg(feature = "http3")]
H3Connection(#[from] h3::error::ConnectionError),
#[error("h3 stream error: {0}")]
#[cfg(feature = "http3")]
H3Stream(#[from] h3::error::StreamError),
#[error("hyper connection: {0}")]
#[cfg(any(feature = "http1", feature = "http2"))]
HyperConnection(Box<dyn std::error::Error + Send + Sync>),
#[error("quinn connection error: {0}")]
#[cfg(feature = "http3")]
QuinnConnection(#[from] h3_quinn::quinn::ConnectionError),
#[error("make service error: {0}")]
ServiceFactoryError(F::Error),
#[error("service error: {0}")]
ServiceError(<F::Service as HttpService>::Error),
#[error("response body error: {0}")]
ResBodyError(<<F::Service as HttpService>::ResBody as http_body::Body>::Error),
}