From ffc541c650789e33b7cbd70a54acbcccde69d4e8 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sun, 13 Nov 2016 02:54:56 +0000 Subject: [PATCH 1/2] Implemented `std::error::Error` trait for error type. --- src/rocksdb.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index cbb69a9..e364b71 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -14,6 +14,7 @@ // use std::collections::BTreeMap; +use std::error; use std::ffi::CString; use std::fmt; use std::fs; @@ -117,6 +118,16 @@ impl From for String { } } +impl error::Error for Error { + fn description(&self) -> &str { + &self.message + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + impl fmt::Display for Error { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.message.fmt(formatter) From 7ea617852ae25065472175177da281134d2db42c Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sun, 13 Nov 2016 12:58:43 +0000 Subject: [PATCH 2/2] Removed redundant default implementation of `cause` fn for error type. --- src/rocksdb.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index e364b71..248957c 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -122,10 +122,6 @@ impl error::Error for Error { fn description(&self) -> &str { &self.message } - - fn cause(&self) -> Option<&error::Error> { - None - } } impl fmt::Display for Error {