mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-10 14:36:51 +00:00
Some movement of helper code and refactoring of error handling
This commit is contained in:
+8
-2
@@ -59,8 +59,8 @@ pub enum Error {
|
||||
)]
|
||||
Quorum(usize, usize, usize, Vec<String>),
|
||||
|
||||
#[error(display = "Bad RPC: {}", _0)]
|
||||
BadRpc(String),
|
||||
#[error(display = "Unexpected RPC message: {}", _0)]
|
||||
UnexpectedRpcMessage(String),
|
||||
|
||||
#[error(display = "Corrupt data: does not match hash {:?}", _0)]
|
||||
CorruptData(Hash),
|
||||
@@ -69,6 +69,12 @@ pub enum Error {
|
||||
Message(String),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn unexpected_rpc_message<T: Serialize>(v: T) -> Self {
|
||||
Self::UnexpectedRpcMessage(debug_serialize(&v))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<sled::transaction::TransactionError<Error>> for Error {
|
||||
fn from(e: sled::transaction::TransactionError<Error>) -> Error {
|
||||
match e {
|
||||
|
||||
Reference in New Issue
Block a user