#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ErrorName {
Timeout,
NotConnected,
InvalidData,
InvalidVersion,
AuthFailed,
Unsupported,
StreamError,
UnknownError,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProxyError {
name: ErrorName,
text: String,
}
impl ProxyError {
pub fn new(name: ErrorName, text: impl Into<String>) -> Self {
Self { name: name, text: text.into() }
}
pub fn name(&self) -> ErrorName {
self.name.clone()
}
pub fn text(&self) -> String {
self.text.clone()
}
}
impl From<std::io::Error> for ProxyError {
fn from(error: std::io::Error) -> Self {
Self {
name: ErrorName::UnknownError,
text: error.to_string(),
}
}
}