aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-03 13:58:05 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:52:46 +0100
commitbeeef4758e5ec0d521179a799a3237c2c0368911 (patch)
treeeb2734647b3c6e62cef64a5f2b533ac694252c29 /src/util
parentd8ab5bdc3e20759e5ba8a6844393757da3539372 (diff)
downloadgarage-beeef4758e5ec0d521179a799a3237c2c0368911.tar.gz
garage-beeef4758e5ec0d521179a799a3237c2c0368911.zip
Some movement of helper code and refactoring of error handling
Diffstat (limited to 'src/util')
-rw-r--r--src/util/error.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util/error.rs b/src/util/error.rs
index ef5a76f2..bdb3a69b 100644
--- a/src/util/error.rs
+++ b/src/util/error.rs
@@ -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 {