From beeef4758e5ec0d521179a799a3237c2c0368911 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 3 Jan 2022 13:58:05 +0100 Subject: Some movement of helper code and refactoring of error handling --- src/util/error.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/util/error.rs') 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), - #[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(v: T) -> Self { + Self::UnexpectedRpcMessage(debug_serialize(&v)) + } +} + impl From> for Error { fn from(e: sled::transaction::TransactionError) -> Error { match e { -- cgit v1.2.3