-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::fmt; | ||
|
||
#[cfg(feature = "v2")] | ||
use bitcoincore_rpc::jsonrpc::serde_json; | ||
use sled::Error as SledError; | ||
|
||
pub(crate) type Result<T> = std::result::Result<T, Error>; | ||
|
||
#[derive(Debug)] | ||
pub(crate) enum Error { | ||
Sled(SledError), | ||
#[cfg(feature = "v2")] | ||
Serialize(serde_json::Error), | ||
#[cfg(feature = "v2")] | ||
Deserialize(serde_json::Error), | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Error::Sled(e) => write!(f, "Database operation failed: {}", e), | ||
#[cfg(feature = "v2")] | ||
Error::Serialize(e) => write!(f, "Serialization failed: {}", e), | ||
#[cfg(feature = "v2")] | ||
Error::Deserialize(e) => write!(f, "Deserialization failed: {}", e), | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for Error {} | ||
|
||
impl From<SledError> for Error { | ||
fn from(error: SledError) -> Self { Error::Sled(error) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters