1#[derive(Debug, Clone, PartialEq, Eq)]
3pub enum ErrorName {
4 Timeout,
5 NotConnected,
6 InvalidData,
7 InvalidVersion,
8 AuthFailed,
9 Unsupported,
10 StreamError,
11 UnknownError,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq)]
16pub struct ProxyError {
17 name: ErrorName,
19
20 text: String,
22}
23
24impl ProxyError {
25 pub fn new(name: ErrorName, text: impl Into<String>) -> Self {
27 Self { name: name, text: text.into() }
28 }
29
30 pub fn name(&self) -> ErrorName {
32 self.name.clone()
33 }
34
35 pub fn text(&self) -> String {
37 self.text.clone()
38 }
39}
40
41impl From<std::io::Error> for ProxyError {
42 fn from(error: std::io::Error) -> Self {
43 Self {
44 name: ErrorName::UnknownError,
45 text: error.to_string(),
46 }
47 }
48}