diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/error.rs b/src/error.rs index 7118fa9..641116e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,8 +1,10 @@ +use std::error::Error as StdError; use std::fmt; use std::str; use libc; use {raw, Session}; +use util::Binding; /// Representation of an error that can occur within libssh2 #[derive(Show)] @@ -23,7 +25,7 @@ impl Error { let rc = raw::libssh2_session_last_error(sess.raw(), &mut msg, 0 as *mut _, 0); if rc == 0 { return None } - let s = ::opt_bytes(&STATIC, msg as *const _).unwrap();; + let s = ::opt_bytes(&STATIC, msg as *const _).unwrap(); Some(Error::new(rc, str::from_utf8(s).unwrap())) } } @@ -106,3 +108,7 @@ impl fmt::String for Error { write!(f, "[{}] {}", self.code, self.msg) } } + +impl StdError for Error { + fn description(&self) -> &str { self.message() } +} |