pub use crate::request::SendError;
pub use anyhow::{anyhow, bail, ensure, Error};
#[derive(Debug, thiserror::Error)]
pub enum NewError {
#[error("invalid HTTP header name")]
InvalidHeaderName,
#[error("invalid HTTP header value")]
InvalidHeaderValue,
#[error("invalid HTTP method")]
InvalidMethod,
#[error("error parsing URL: {0}")]
UrlParseError(#[from] url::ParseError),
}
impl From<std::convert::Infallible> for NewError {
fn from(_: std::convert::Infallible) -> Self {
unreachable!()
}
}
impl From<http::header::InvalidHeaderName> for NewError {
fn from(_: http::header::InvalidHeaderName) -> Self {
Self::InvalidHeaderName
}
}
impl From<http::header::InvalidHeaderValue> for NewError {
fn from(_: http::header::InvalidHeaderValue) -> Self {
Self::InvalidHeaderValue
}
}
impl From<http::method::InvalidMethod> for NewError {
fn from(_: http::method::InvalidMethod) -> Self {
Self::InvalidMethod
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, thiserror::Error)]
#[error("insufficient buffer size {buf_size}; value requires {needed_buf_size} bytes")]
pub struct BufferSizeError {
pub buf_size: usize,
pub needed_buf_size: usize,
}
impl BufferSizeError {
pub(crate) fn new(buf_size: usize, needed_buf_size: usize) -> Self {
Self {
buf_size,
needed_buf_size,
}
}
}