mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
impl error for rocksdb::Error
This commit is contained in:
10
src/error.rs
10
src/error.rs
@@ -38,6 +38,7 @@ pub enum Error {
|
||||
ZMQError(String),
|
||||
VerifyFailed,
|
||||
TryIntoError,
|
||||
RocksdbError(String),
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
||||
@@ -73,10 +74,13 @@ impl fmt::Display for Error {
|
||||
Error::ZMQError(ref err) => write!(f, "ZMQError: {}", err),
|
||||
Error::VerifyFailed => f.write_str("Verify failed"),
|
||||
Error::TryIntoError => f.write_str("TryInto get an error"),
|
||||
Error::RocksdbError(ref err) => write!(f, "Rocksdb Error: {}", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: Match statement to parse external errors into strings.
|
||||
impl From<zeromq::ZmqError> for Error {
|
||||
fn from(err: zeromq::ZmqError) -> Error {
|
||||
@@ -84,6 +88,12 @@ impl From<zeromq::ZmqError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<rocksdb::Error> for Error {
|
||||
fn from(err: rocksdb::Error) -> Error {
|
||||
Error::RocksdbError(err.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
fn from(err: std::io::Error) -> Error {
|
||||
Error::Io(err.kind())
|
||||
|
||||
Reference in New Issue
Block a user