msedge_tts/
error.rs

1//! Error Type
2
3use thiserror::Error;
4
5pub type Result<T, E = Error> = std::result::Result<T, E>;
6
7#[derive(Error, Debug)]
8pub enum Error {
9    #[error("unexpected message: {0}")]
10    UnexpectedMessage(String),
11    #[error("isahc error: {0}")]
12    IsahcError(#[from] isahc::Error),
13    #[error("tungstenite error: {0}")]
14    TungsteniteError(#[from] tungstenite::Error),
15    #[error("serde json error: {0}")]
16    SerdeJsonError(#[from] serde_json::Error),
17    #[error("proxy error: {0}")]
18    ProxyError(#[from] ProxyError),
19}
20
21/// Proxy Error
22#[derive(Error, Debug)]
23pub enum ProxyError {
24    #[error("not supported scheme: {0}")]
25    NotSupportedScheme(http::Uri),
26    #[error("http proxy error: {0}")]
27    HttpProxyError(#[from] HttpProxyError),
28    #[error("socks4 proxy error: {0}")]
29    Socks4ProxyError(#[from] Socks4ProxyError),
30    #[error("socks5 proxy error: {0}")]
31    Socks5ProxyError(#[from] Socks5ProxyError),
32}
33
34/// Http Proxy Error
35#[derive(Error, Debug)]
36pub enum HttpProxyError {
37    #[error("no proxy server host name: {0}")]
38    NoProxyServerHostName(http::Uri),
39    #[error("proxy host name is empty: {0}")]
40    EmptyProxyServerHostName(http::Uri),
41    #[error("io error: {0}")]
42    IoError(#[from] std::io::Error),
43    #[error("native tls error: {0}")]
44    NativeTlsError(#[from] native_tls::Error),
45    #[error("invalid response: {0}")]
46    InvalidResponse(#[from] httparse::Error),
47    #[error("bad response: {0} {1}")]
48    BadResponse(u16, String),
49    #[error("no status code")]
50    NoStatusCode,
51    #[error("not supported scheme: {0}")]
52    NotSupportedScheme(http::Uri),
53}
54
55/// Socks4 Proxy Error
56#[derive(Error, Debug)]
57pub enum Socks4ProxyError {
58    #[error("no proxy server host name: {0}")]
59    NoProxyServerHostName(http::Uri),
60    #[error("no proxy server port: {0}")]
61    NoProxyServerPort(http::Uri),
62    #[error("proxy host name is empty: {0}")]
63    EmptyProxyServerHostName(http::Uri),
64    #[error("io error: {0}")]
65    IoError(#[from] std::io::Error),
66    #[error("empty scheme: {0}")]
67    NoScheme(http::Uri),
68    #[error("not supported scheme: {0}")]
69    NotSupportedScheme(http::Uri),
70    #[error("lookup ip v4 addrs failed: {0}")]
71    NoIpV4Addr(String),
72    #[error("request rejected or failed")]
73    RequestRejectedOrFailed(u8),
74    #[error("no available identd service")]
75    NoneAvailableIdentdService(u8),
76    #[error("identd check failed: {0}")]
77    IdentdCheckFailed(u8),
78    #[error("unknown reply code: {0}")]
79    UnknownReplyCode(u8),
80}
81
82/// Socks5 Proxy Error
83#[derive(Error, Debug)]
84pub enum Socks5ProxyError {
85    #[error("no proxy server host name: {0}")]
86    NoProxyServerHostName(http::Uri),
87    #[error("no proxy server port: {0}")]
88    NoProxyServerPort(http::Uri),
89    #[error("proxy host name is empty: {0}")]
90    EmptyProxyServerHostName(http::Uri),
91    #[error("io error: {0}")]
92    IoError(#[from] std::io::Error),
93    #[error("empty scheme: {0}")]
94    NoScheme(http::Uri),
95    #[error("not supported scheme: {0}")]
96    NotSupportedScheme(http::Uri),
97    #[error("bad response version: {0}")]
98    BadResponseVersion(u8),
99    #[error("bad server choice: {0:?}")]
100    BadServerChoice(u8),
101    #[error("client authentication failed: {0:?}")]
102    ClientAuthenticationFailed([u8; 2]),
103    #[error("lookup ip addrs failed: {0}")]
104    NoIpAddr(String),
105    #[error("not supported server bind address type: {0}")]
106    NotSupportedServerBindAddressType(u8),
107    #[error("general failure: {0}")]
108    GeneralFailure(u8),
109    #[error("connection not allowed by rules: {0}")]
110    ConnectionNotAllowedByRules(u8),
111    #[error("network unreachable: {0}")]
112    NetworkUnreachable(u8),
113    #[error("host unreachable: {0}")]
114    HostUnreachable(u8),
115    #[error("connection refused: {0}")]
116    ConnectionRefused(u8),
117    #[error("ttl expired: {0}")]
118    TtlExpired(u8),
119    #[error("command not supported: {0}")]
120    CommandNotSupported(u8),
121    #[error("address type not supported: {0}")]
122    AddressTypeNotSupported(u8),
123    #[error("unknown reply code: {0}")]
124    UnknownReplyCode(u8),
125}