mock_http_connector/
error.rs

1use std::error::Error as StdError;
2
3use crate::case::Checkpoint;
4
5/// Errors generated by this crate
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    /// Errors while checking if all mock cases were called the right number of times
9    #[error("checkpoint error: {0:?}")]
10    Checkpoint(Vec<Checkpoint>),
11
12    /// Error from the [`hyper`] crate
13    #[error("hyper error: {0}")]
14    Hyper(#[from] crate::hyper::Error),
15
16    /// Error from [`hyper::http`]
17    #[error("http error: {0}")]
18    Http(#[from] crate::hyper::http::Error),
19
20    /// Error from [`hyper_util`]
21    #[cfg(feature = "hyper_1")]
22    #[error("hyper_util client error: {0}")]
23    HyperLegacy(#[from] hyper_util::client::legacy::Error),
24
25    /// Error from [`httparse`]
26    #[error("httparse error: {0}")]
27    Httparse(#[from] httparse::Error),
28
29    /// JSON serialization/deserialization error
30    #[cfg(feature = "json")]
31    #[error("JSON serde error: {0}")]
32    Json(#[from] serde_json::Error),
33
34    /// No match found for the incoming [`Request`]
35    #[error("no cases matched the request: {0:?}")]
36    NotFound(crate::hyper::Request<String>),
37
38    /// Runtime errors
39    #[error("transparent")]
40    Runtime(#[from] BoxError),
41}
42
43pub type BoxError = Box<dyn StdError + Send + Sync>;