aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/error.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-12-12 15:46:17 -0800
committerSteven Fackler <[email protected]>2015-12-12 15:46:17 -0800
commitd6ce9afdf31faacaf435380feffcd13bf387255a (patch)
tree3a9251bb151561e1cad9ceba5f5c66e01edb8388 /openssl/src/ssl/error.rs
parentBuild out a new error type (diff)
downloadrust-openssl-d6ce9afdf31faacaf435380feffcd13bf387255a.tar.xz
rust-openssl-d6ce9afdf31faacaf435380feffcd13bf387255a.zip
Have NonblockingSslStream delegate to SslStream
Diffstat (limited to 'openssl/src/ssl/error.rs')
-rw-r--r--openssl/src/ssl/error.rs29
1 files changed, 18 insertions, 11 deletions
diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs
index 9a1a63b2..52ea6693 100644
--- a/openssl/src/ssl/error.rs
+++ b/openssl/src/ssl/error.rs
@@ -95,6 +95,11 @@ impl OpenSslError {
errs
}
+ /// Returns the raw OpenSSL error code for this error.
+ pub fn error_code(&self) -> c_ulong {
+ self.0
+ }
+
/// Returns the name of the library reporting the error.
pub fn library(&self) -> &'static str {
get_lib(self.0)
@@ -239,6 +244,17 @@ pub enum OpensslError {
}
}
+impl OpensslError {
+ pub fn from_error_code(err: c_ulong) -> OpensslError {
+ ffi::init();
+ UnknownError {
+ library: get_lib(err).to_owned(),
+ function: get_func(err).to_owned(),
+ reason: get_reason(err).to_owned()
+ }
+ }
+}
+
fn get_lib(err: c_ulong) -> &'static str {
unsafe {
let cstr = ffi::ERR_lib_error_string(err);
@@ -271,7 +287,7 @@ impl SslError {
loop {
match unsafe { ffi::ERR_get_error() } {
0 => break,
- err => errs.push(SslError::from_error_code(err))
+ err => errs.push(OpensslError::from_error_code(err))
}
}
OpenSslErrors(errs)
@@ -279,16 +295,7 @@ impl SslError {
/// Creates an `SslError` from the raw numeric error code.
pub fn from_error(err: c_ulong) -> SslError {
- OpenSslErrors(vec![SslError::from_error_code(err)])
- }
-
- fn from_error_code(err: c_ulong) -> OpensslError {
- ffi::init();
- UnknownError {
- library: get_lib(err).to_owned(),
- function: get_func(err).to_owned(),
- reason: get_reason(err).to_owned()
- }
+ OpenSslErrors(vec![OpensslError::from_error_code(err)])
}
}