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    NoInitialCipherSuite(#[from] h3_quinn::quinn::crypto::rustls::NoInitialCipherSuite),
24    /// h3 connection error.
25    ///
26    /// Refer to [`h3::error::ConnectionError`] for more information.
27    #[error("h3 connection error: {0}")]
28    #[cfg(feature = "http3")]
29    H3Connection(#[from] h3::error::ConnectionError),
30    /// h3 stream error.
31    ///
32    /// Refer to [`h3::error::StreamError`] for more information.
33    #[error("h3 stream error: {0}")]
34    #[cfg(feature = "http3")]
35    H3Stream(#[from] h3::error::StreamError),
36    /// An error that occurred while handling a hyper connection.
37    #[error("hyper connection: {0}")]
38    #[cfg(any(feature = "http1", feature = "http2"))]
39    HyperConnection(Box<dyn std::error::Error + Send + Sync>),
40    /// An error that occurred while handling a quinn connection.
41    #[error("quinn connection error: {0}")]
42    #[cfg(feature = "http3")]
43    QuinnConnection(#[from] h3_quinn::quinn::ConnectionError),
44    /// An error that occurred while calling [`HttpServiceFactory::new_service`].
45    #[error("make service error: {0}")]
46    ServiceFactoryError(F::Error),
47    /// An error that occurred while calling [`HttpService::call`].
48    #[error("service error: {0}")]
49    ServiceError(<F::Service as HttpService>::Error),
50    /// An error that occurred while sending a response body.
51    #[error("response body error: {0}")]
52    ResBodyError(<<F::Service as HttpService>::ResBody as http_body::Body>::Error),
53}