From ffc541c650789e33b7cbd70a54acbcccde69d4e8 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sun, 13 Nov 2016 02:54:56 +0000 Subject: [PATCH] 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)