diff options
| author | Steven Fackler <[email protected]> | 2013-10-23 21:28:08 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2013-10-23 21:28:08 -0700 |
| commit | 7ea442be94ac1450d5d9d6c5670c10b0e7a5b05a (patch) | |
| tree | 989b2707a303d40d1eb9dbf7b02364c21e360e37 /error.rs | |
| parent | Slightly better error handling (diff) | |
| download | rust-openssl-7ea442be94ac1450d5d9d6c5670c10b0e7a5b05a.tar.xz rust-openssl-7ea442be94ac1450d5d9d6c5670c10b0e7a5b05a.zip | |
Ssl errors may return a stack
Diffstat (limited to 'error.rs')
| -rw-r--r-- | error.rs | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -6,6 +6,11 @@ use super::ffi; pub enum SslError { StreamEof, SslSessionClosed, + OpenSslErrors(~[OpensslError]) +} + +#[deriving(ToStr)] +pub enum OpensslError { UnknownError { library: u8, function: u16, @@ -26,14 +31,18 @@ fn get_reason(err: c_ulong) -> u16 { } impl SslError { - pub fn get() -> Option<SslError> { - match unsafe { ffi::ERR_get_error() } { - 0 => None, - err => Some(UnknownError { - library: get_lib(err), - function: get_func(err), - reason: get_reason(err) - }) + pub fn get() -> SslError { + let mut errs = ~[]; + loop { + match unsafe { ffi::ERR_get_error() } { + 0 => break, + err => errs.push(UnknownError { + library: get_lib(err), + function: get_func(err), + reason: get_reason(err) + }) + } } + OpenSslErrors(errs) } } |