diff options
| author | Steven Fackler <[email protected]> | 2015-02-16 22:21:13 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2015-02-16 22:21:13 -0800 |
| commit | f0eb8e39e3af70c7e0322f0d698f6714ad723c62 (patch) | |
| tree | 28b265bf1ea4cda743d389302a72399950ffb5a9 /openssl/src/ssl/error.rs | |
| parent | Release v0.4.0 (diff) | |
| download | rust-openssl-f0eb8e39e3af70c7e0322f0d698f6714ad723c62.tar.xz rust-openssl-f0eb8e39e3af70c7e0322f0d698f6714ad723c62.zip | |
Deal with openssl errors in read
I'm not sure of a great way to generate this case in a test,
unfortunately.
Closes #157
Diffstat (limited to 'openssl/src/ssl/error.rs')
| -rw-r--r-- | openssl/src/ssl/error.rs | 18 |
1 files changed, 17 insertions, 1 deletions
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(()) } } |