aboutsummaryrefslogtreecommitdiff
path: root/src/rpc_client.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-23 16:23:06 +0000
committerAlex Auvolat <alex@adnab.me>2020-04-23 16:23:06 +0000
commit01a8acdeecfcacafb61809f9e135709148e842ce (patch)
treef28e39d919f4f162efb21aa0692c5b0cc6e6949a /src/rpc_client.rs
parent82f4cd87195e61552348ae9d1cd27096253a4187 (diff)
downloadgarage-01a8acdeecfcacafb61809f9e135709148e842ce.tar.gz
garage-01a8acdeecfcacafb61809f9e135709148e842ce.zip
Better error reporting
Diffstat (limited to 'src/rpc_client.rs')
-rw-r--r--src/rpc_client.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/rpc_client.rs b/src/rpc_client.rs
index c083fcfd..ba036c60 100644
--- a/src/rpc_client.rs
+++ b/src/rpc_client.rs
@@ -41,6 +41,8 @@ pub enum RPCError {
RMPEncode(#[error(source)] rmp_serde::encode::Error),
#[error(display = "Messagepack decode error: {}", _0)]
RMPDecode(#[error(source)] rmp_serde::decode::Error),
+ #[error(display = "Too many errors: {:?}", _0)]
+ TooManyErrors(Vec<String>),
}
#[derive(Copy, Clone)]
@@ -222,11 +224,8 @@ impl<M: RpcMessage + 'static> RpcClient<M> {
Ok(results)
} else {
- let mut msg = "Too many failures:".to_string();
- for e in errors {
- msg += &format!("\n{}", e);
- }
- Err(Error::Message(msg))
+ let errors = errors.iter().map(|e| format!("{}", e)).collect::<Vec<_>>();
+ Err(Error::from(RPCError::TooManyErrors(errors)))
}
}
}