scuffle_http/
error.rs

1//! Error types.
2use std::fmt::Debug;
3
4use crate::service::{HttpService, HttpServiceFactory};
5
6/// An error that can occur when creating or running an HTTP server.
7#[derive(Debug, thiserror::Error)]
8pub enum HttpError<F>
9where
10    F: HttpServiceFactory,
11    F::Error: std::error::Error,
12    <F::Service as HttpService>::Error: std::error::Error,
13    <<F::Service as HttpService>::ResBody as http_body::Body>::Error: std::error::Error,
14{
15    /// An I/O error.
16    #[error("io error: {0}")]
17    Io(#[from] std::io::Error),
18    /// No initial cipher suite.
19    ///
20    /// Refer to [`h3_quinn::quinn::crypto::rustls::NoInitialCipherSuite`] for more information.
21    #[error("{0}")]
22    #[cfg(all(feature = "http3", feature = "tls-rustls"))]
23    #[cfg_attr(docsrs, doc(cfg(all(feature = "http3", feature = "tls-rustls"))))]
24    NoInitialCipherSuite(#[from] h3_quinn::quinn::crypto::rustls::NoInitialCipherSuite),
25    /// Any h3 error.
26    ///
27    /// Refer to [`h3::Error`] for more information.
28    #[error("h3 error: {0}")]
29    #[cfg(feature = "http3")]
30    #[cfg_attr(docsrs, doc(cfg(feature = "http3")))]
31    H3(#[from] h3::Error),
32    /// An error that occurred while handling a hyper connection.
33    #[error("hyper connection: {0}")]
34    #[cfg(any(feature = "http1", feature = "http2"))]
35    #[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
36    HyperConnection(Box<dyn std::error::Error + Send + Sync>),
37    /// An error that occurred while handling a quinn connection.
38    #[error("quinn connection error: {0}")]
39    #[cfg(feature = "http3")]
40    #[cfg_attr(docsrs, doc(cfg(feature = "http3")))]
41    QuinnConnection(#[from] h3_quinn::quinn::ConnectionError),
42    /// An error that occurred while calling [`HttpServiceFactory::new_service`].
43    #[error("make service error: {0}")]
44    ServiceFactoryError(F::Error),
45    /// An error that occurred while calling [`HttpService::call`].
46    #[error("service error: {0}")]
47    ServiceError(<F::Service as HttpService>::Error),
48    /// An error that occurred while sending a response body.
49    #[error("response body error: {0}")]
50    ResBodyError(<<F::Service as HttpService>::ResBody as http_body::Body>::Error),
51}