Tweak yet again the boring error reporting

We also omit file and line in ErrorStack itself now too.

ErrorStack is the wrapped error type returned by
hyper_boring::HttpsConnector::call.
This commit is contained in:
Anthony Ramine 2021-03-15 10:56:53 +01:00
parent 7f6bd732e4
commit 56564c7cb6
2 changed files with 5 additions and 7 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 OpenSSL 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

@ -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) => {
@ -179,9 +179,7 @@ fn fmt_mid_handshake_error(
}
if let Some(error) = s.error().ssl_error() {
for error in error.errors() {
write!(f, " [{}]", error.reason().unwrap_or("unknown error"),)?;
}
write!(f, " {}", error)?;
}
Ok(())