mock-http-connector 0.5.0

Mock hyper HTTPConnector
Documentation
use std::error::Error as StdError;

use crate::case::Checkpoint;

/// Errors generated by this crate
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// Errors while checking if all mock cases were called the right number of times
    #[error("checkpoint error: {0:?}")]
    Checkpoint(Vec<Checkpoint>),

    /// Error from the [`hyper`] crate
    #[error("hyper error: {0}")]
    Hyper(#[from] crate::hyper::Error),

    /// Error from [`hyper::http`]
    #[error("http error: {0}")]
    Http(#[from] crate::hyper::http::Error),

    /// Error from [`hyper_util`]
    #[cfg(feature = "hyper_1")]
    #[error("hyper_util client error: {0}")]
    HyperLegacy(#[from] hyper_util::client::legacy::Error),

    /// Error from [`httparse`]
    #[error("httparse error: {0}")]
    Httparse(#[from] httparse::Error),

    /// JSON serialization/deserialization error
    #[cfg(feature = "json")]
    #[error("JSON serde error: {0}")]
    Json(#[from] serde_json::Error),

    /// No match found for the incoming [`Request`]
    #[error("no cases matched the request: {0:?}")]
    NotFound(crate::hyper::Request<String>),

    /// Runtime errors
    #[error("transparent")]
    Runtime(#[from] BoxError),
}

pub type BoxError = Box<dyn StdError + Send + Sync>;