http_type/request/
error.rs1use std::{
2 error::Error as StdError,
3 fmt::{self, Display},
4};
5
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum Error {
8 HttpReadError,
9 InvalidHttpRequest,
10 InvalidUrl,
11 TcpStreamConnectError,
12 RequestError,
13 MethodsNotSupport,
14 ReadConnectionError,
15 TlsConnectorBuildError,
16 SetReadTimeoutError,
17 SetWriteTimeoutError,
18 TlsStreamConnectError,
19 MaxRedirectTimes,
20 RedirectUrlDeadLoop,
21 RedirectInvalidUrl,
22 NeedOpenRedirect,
23 Unknown,
24}
25
26impl StdError for Error {}
27
28impl Display for Error {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 Self::HttpReadError => write!(f, "Http read error"),
32 Self::InvalidHttpRequest => write!(f, "Invalid http request"),
33 Self::InvalidUrl => write!(f, "Invalid URL"),
34 Self::TcpStreamConnectError => write!(f, "TCP Stream Connection Error"),
35 Self::RequestError => write!(f, "Request Error"),
36 Self::MethodsNotSupport => write!(f, "Unsupported HTTP Method"),
37 Self::ReadConnectionError => write!(f, "Connection Read Error"),
38 Self::TlsConnectorBuildError => write!(f, "TLS Connector Build Error"),
39 Self::SetReadTimeoutError => write!(f, "Failed to Set Read Timeout"),
40 Self::SetWriteTimeoutError => write!(f, "Failed to Set Write Timeout"),
41 Self::TlsStreamConnectError => write!(f, "TLS Stream Connection Error"),
42 Self::MaxRedirectTimes => write!(f, "Max Redirect Times"),
43 Self::RedirectUrlDeadLoop => write!(f, "Redirect URL Dead Loop"),
44 Self::RedirectInvalidUrl => write!(f, "Redirect Invalid Url"),
45 Self::NeedOpenRedirect => write!(f, "Need Open Redirect"),
46 Self::Unknown => write!(f, "{}", "Unknown"),
47 }
48 }
49}