use std::io;
use std::convert::From;

pub type HttpResult<T> = Result<T, HttpError>;

#[derive(Debug)]
pub enum HttpError {
    IoError(io::Error),
    Utf8Error(std::str::Utf8Error),
    UrlParseError(url::ParseError),
}

impl From<io::Error> for HttpError {
    fn from(err: io::Error) -> Self {
        HttpError::IoError(err)
    }
}

impl From<std::str::Utf8Error> for HttpError {
    fn from(err: std::str::Utf8Error) -> Self {
        HttpError::Utf8Error(err)
    }
}

impl From<url::ParseError> for HttpError {
    fn from(err: url::ParseError) -> Self {
        HttpError::UrlParseError(err)
    }
}
