diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs index 027554c5..a80c244e 100644 --- a/openssl/src/ssl/error.rs +++ b/openssl/src/ssl/error.rs @@ -22,7 +22,23 @@ pub enum SslError { impl fmt::Display for SslError { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.write_str(error::Error::description(self)) + try!(fmt.write_str(error::Error::description(self))); + if let OpenSslErrors(ref errs) = *self { + let mut first = true; + for err in errs { + if first { + try!(fmt.write_str(": ")); + first = false; + } else { + try!(fmt.write_str(", ")); + } + match *err { + UnknownError { ref reason, .. } => try!(fmt.write_str(reason)), + } + } + } + + Ok(()) } } diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index c9d46ffc..0c698f54 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -1,6 +1,6 @@ use libc::{c_int, c_void, c_long}; use std::ffi::{CString, c_str_to_bytes}; -use std::old_io::{IoResult, IoError, EndOfFile, Stream, Reader, Writer}; +use std::old_io::{IoResult, IoError, EndOfFile, OtherIoError, Stream, Reader, Writer}; use std::mem; use std::fmt; use std::num::FromPrimitive; @@ -9,7 +9,7 @@ use std::sync::{Once, ONCE_INIT, Arc}; use bio::{MemBio}; use ffi; -use ssl::error::{SslError, SslSessionClosed, StreamError}; +use ssl::error::{SslError, SslSessionClosed, StreamError, OpenSslErrors}; use x509::{X509StoreContext, X509FileType, X509}; pub mod error; @@ -559,7 +559,13 @@ impl Reader for SslStream { detail: None }), Err(StreamError(e)) => Err(e), - _ => unreachable!() + Err(e @ OpenSslErrors(_)) => { + Err(IoError { + kind: OtherIoError, + desc: "SSL error", + detail: Some(format!("{}", e)), + }) + } } } }