Merge pull request #19 from nox/errors

Tweak yet again the boring error reporting
This commit is contained in:
Ivan Nikulin 2021-03-15 14:15:26 +00:00 committed by GitHub
commit 9fd89aba60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 16 deletions

View File

@ -60,16 +60,16 @@ impl ErrorStack {
impl fmt::Display for ErrorStack {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
if self.0.is_empty() {
return fmt.write_str("OpenSSL error");
return fmt.write_str("unknown BoringSSL error");
}
let mut first = true;
for err in &self.0 {
if !first {
fmt.write_str("\n--\n")?;
fmt.write_str(" ")?;
}
write!(fmt, "{}", err)?;
first = false;
write!(fmt, "[{}]", err.reason().unwrap_or("unknown reason"))?;
}
Ok(())
}

View File

@ -110,7 +110,7 @@ impl fmt::Display for Error {
},
ErrorCode::SSL => match self.ssl_error() {
Some(e) => write!(fmt, "{}", e),
None => fmt.write_str("OpenSSL error"),
None => fmt.write_str("unknown BoringSSL error"),
},
ErrorCode(code) => write!(fmt, "unknown error code {}", code),
}
@ -154,7 +154,7 @@ impl<S> fmt::Display for HandshakeError<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
HandshakeError::SetupFailure(ref e) => {
write!(f, "TLS stream setup failed:\n\n{}", e)
write!(f, "TLS stream setup failed {}", e)
}
HandshakeError::Failure(ref s) => fmt_mid_handshake_error(s, f, "TLS handshake failed"),
HandshakeError::WouldBlock(ref s) => {
@ -174,17 +174,7 @@ fn fmt_mid_handshake_error(
verify => write!(f, "{}: cert verification failed - {}", prefix, verify)?,
}
if let Some(error) = s.error().io_error() {
return write!(f, " ({})", error);
}
if let Some(error) = s.error().ssl_error() {
for error in error.errors() {
write!(f, " [{}]", error.reason().unwrap_or("unknown error"),)?;
}
}
Ok(())
write!(f, " {}", s.error())
}
impl<S> From<ErrorStack> for HandshakeError<S> {