under/
error.rs

1#[derive(thiserror::Error, Debug)]
2#[non_exhaustive]
3/// Errors generated specifically from this library, and not its interactions
4/// user code.
5pub enum UnderError {
6    #[error("could not parse the given string ({:?}) as an address", .0)]
7    /// Generated when attempting to parse an address (during
8    /// [`crate::Router::listen`]), but the address was invalid.
9    InvalidAddress(String),
10    #[error("could not serve server")]
11    /// Generated when attempting to bind and listen using hyper, but it failed
12    /// for some underlying reason.
13    HyperServer(#[source] hyper::Error),
14    /// Generated when attempting to read the body of a request, or response,
15    /// and failing.
16    #[error("could not read the body of a request or response")]
17    ReadBody(#[source] std::io::Error),
18    #[cfg(feature = "json")]
19    #[cfg_attr(nightly, doc(cfg(feature = "json")))]
20    /// Generated when attempting to deserialize the body of a request or
21    /// response from JSON.
22    #[error("could not deserialize the body of a request or response from JSON")]
23    JsonDeserialization(#[source] serde_json::Error),
24    #[cfg(feature = "cbor")]
25    #[cfg_attr(nightly, doc(cfg(feature = "cbor")))]
26    /// Generated when attempting to deserialize the body of a request or
27    /// response from CBOR.
28    #[error("could not deserialize the body of a request or response from CBOR")]
29    CborDeserialization(#[source] anyhow::Error),
30    #[cfg(feature = "msgpack")]
31    #[cfg_attr(nightly, doc(cfg(feature = "msgpack")))]
32    /// Generated when attempting to deserialize the body of a request or
33    /// response from MessagePack.
34    #[error("could not deserialize the body of a request or response from MessagePack")]
35    MsgpackDeserialization(#[source] rmp_serde::decode::Error),
36    /// Generated when attempting to deserialize the body of a request or
37    /// response from text.
38    #[error("could not deserialize the body of a request or response from utf-8")]
39    TextDeserialization(#[source] std::string::FromUtf8Error),
40    #[cfg(feature = "from_form")]
41    #[cfg_attr(nightly, doc(cfg(feature = "from_form")))]
42    /// Generated when attempting to deserialize the body of a request or
43    /// response from x-www-form-urlencoded.
44    #[error("could not deserialize the body of a request or response from urlencoded")]
45    FormDeserialization(#[source] crate::from_form::FromFormError),
46    /// Generated when attempting to sniff the request or response of its
47    /// content type.
48    #[error("the content-type of the request was invalid")]
49    UnsupportedMediaType(Option<mime::Mime>),
50    /// Generated when the request body of the request (if not provided with
51    /// a Content-Length header) is too large.
52    #[error("the request body of the request was too long, and was cut off")]
53    PayloadTooLarge(#[source] anyhow::Error),
54}