mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 16:14:11 +00:00
Resolved deprecated std::error::Error functions
This commit is contained in:
+1
-13
@@ -437,19 +437,7 @@ impl fmt::Display for UrlParseError {
|
||||
}
|
||||
|
||||
impl error::Error for UrlParseError {
|
||||
fn description(&self) -> &str {
|
||||
match *self {
|
||||
UrlParseError::ParseError(ref err) => error::Error::description(err),
|
||||
UrlParseError::InvalidScheme => "URL must have \"ss://\" scheme",
|
||||
UrlParseError::InvalidUserInfo => "invalid user info",
|
||||
UrlParseError::MissingHost => "missing host",
|
||||
UrlParseError::InvalidAuthInfo => "invalid authentication info",
|
||||
UrlParseError::InvalidServerAddr => "invalid server address",
|
||||
UrlParseError::InvalidQueryString => "invalid query string",
|
||||
}
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&dyn error::Error> {
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
match *self {
|
||||
UrlParseError::ParseError(ref err) => Some(err as &dyn error::Error),
|
||||
UrlParseError::InvalidScheme => None,
|
||||
|
||||
+7
-12
@@ -166,10 +166,13 @@ pub struct Error {
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn new(reply: Reply, message: &str) -> Error {
|
||||
pub fn new<S>(reply: Reply, message: S) -> Error
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Error {
|
||||
reply,
|
||||
message: message.to_string(),
|
||||
message: message.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,19 +191,11 @@ impl fmt::Display for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for Error {
|
||||
fn description(&self) -> &str {
|
||||
&self.message[..]
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&dyn error::Error> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl error::Error for Error {}
|
||||
|
||||
impl From<io::Error> for Error {
|
||||
fn from(err: io::Error) -> Error {
|
||||
Error::new(Reply::GeneralFailure, <io::Error as error::Error>::description(&err))
|
||||
Error::new(Reply::GeneralFailure, err.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user