remove deprecated Error::description, replace deprecated cause with source

This commit is contained in:
Andrii Radyk 2019-12-21 23:53:49 +01:00
parent 0815ac9b5d
commit fc3c0a93d5
3 changed files with 15 additions and 33 deletions

View File

@ -75,11 +75,7 @@ impl fmt::Display for ErrorStack {
} }
} }
impl error::Error for ErrorStack { impl error::Error for ErrorStack {}
fn description(&self) -> &str {
"An OpenSSL error stack"
}
}
impl From<ErrorStack> for io::Error { impl From<ErrorStack> for io::Error {
fn from(e: ErrorStack) -> io::Error { fn from(e: ErrorStack) -> io::Error {
@ -285,8 +281,4 @@ impl fmt::Display for Error {
} }
} }
impl error::Error for Error { impl error::Error for Error {}
fn description(&self) -> &str {
"an OpenSSL error"
}
}

View File

@ -123,11 +123,7 @@ impl fmt::Display for Error {
} }
impl error::Error for Error { impl error::Error for Error {
fn description(&self) -> &str { fn source(&self) -> Option<&(dyn error::Error + 'static)> {
"an OpenSSL error"
}
fn cause(&self) -> Option<&dyn error::Error> {
match self.cause { match self.cause {
Some(InnerError::Io(ref e)) => Some(e), Some(InnerError::Io(ref e)) => Some(e),
Some(InnerError::Ssl(ref e)) => Some(e), Some(InnerError::Ssl(ref e)) => Some(e),
@ -151,15 +147,7 @@ pub enum HandshakeError<S> {
} }
impl<S: fmt::Debug> StdError for HandshakeError<S> { impl<S: fmt::Debug> StdError for HandshakeError<S> {
fn description(&self) -> &str { fn source(&self) -> Option<&(dyn StdError + 'static)> {
match *self {
HandshakeError::SetupFailure(_) => "stream setup failed",
HandshakeError::Failure(_) => "the handshake failed",
HandshakeError::WouldBlock(_) => "the handshake was interrupted",
}
}
fn cause(&self) -> Option<&dyn StdError> {
match *self { match *self {
HandshakeError::SetupFailure(ref e) => Some(e), HandshakeError::SetupFailure(ref e) => Some(e),
HandshakeError::Failure(ref s) | HandshakeError::WouldBlock(ref s) => Some(s.error()), HandshakeError::Failure(ref s) | HandshakeError::WouldBlock(ref s) => Some(s.error()),
@ -169,11 +157,17 @@ impl<S: fmt::Debug> StdError for HandshakeError<S> {
impl<S: fmt::Debug> fmt::Display for HandshakeError<S> { impl<S: fmt::Debug> fmt::Display for HandshakeError<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(StdError::description(self))?;
match *self { match *self {
HandshakeError::SetupFailure(ref e) => write!(f, ": {}", e)?, HandshakeError::SetupFailure(ref e) => write!(f, "stream setup failed: {}", e)?,
HandshakeError::Failure(ref s) | HandshakeError::WouldBlock(ref s) => { HandshakeError::Failure(ref s) => {
write!(f, ": {}", s.error())?; write!(f, "the handshake failed: {}", s.error())?;
let verify = s.ssl().verify_result();
if verify != X509VerifyResult::OK {
write!(f, ": {}", verify)?;
}
}
HandshakeError::WouldBlock(ref s) => {
write!(f, "the handshake was interrupted: {}", s.error())?;
let verify = s.ssl().verify_result(); let verify = s.ssl().verify_result();
if verify != X509VerifyResult::OK { if verify != X509VerifyResult::OK {
write!(f, ": {}", verify)?; write!(f, ": {}", verify)?;

View File

@ -1189,11 +1189,7 @@ impl fmt::Display for X509VerifyResult {
} }
} }
impl Error for X509VerifyResult { impl Error for X509VerifyResult {}
fn description(&self) -> &str {
"an X509 validation error"
}
}
impl X509VerifyResult { impl X509VerifyResult {
/// Creates an `X509VerifyResult` from a raw error number. /// Creates an `X509VerifyResult` from a raw error number.