aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-12-14 16:11:19 +0100
committerAlex Auvolat <alex@adnab.me>2022-12-14 16:11:19 +0100
commite6f14ab5cfe985106092afa228258eeb7d5d8905 (patch)
tree75d07de43595127a8c8fe461bbebe65b040408d1
parent510b62010871e9133a98f625b85f07a7e50f6f23 (diff)
downloadgarage-e6f14ab5cfe985106092afa228258eeb7d5d8905.tar.gz
garage-e6f14ab5cfe985106092afa228258eeb7d5d8905.zip
better error message handling
-rw-r--r--src/rpc/system.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/rpc/system.rs b/src/rpc/system.rs
index f03df509..8f753b7f 100644
--- a/src/rpc/system.rs
+++ b/src/rpc/system.rs
@@ -436,16 +436,13 @@ impl System {
})?;
let mut errors = vec![];
for addr in addrs.iter() {
- match self
- .netapp
- .clone()
- .try_connect(*addr, pubkey)
- .await
- .err_context(connect_error_message(*addr, pubkey))
- {
+ match self.netapp.clone().try_connect(*addr, pubkey).await {
Ok(()) => return Ok(()),
Err(e) => {
- errors.push((*addr, e));
+ errors.push((
+ *addr,
+ Error::Message(connect_error_message(*addr, pubkey, e)),
+ ));
}
}
}
@@ -766,7 +763,7 @@ impl System {
let self2 = self.clone();
tokio::spawn(async move {
if let Err(e) = self2.netapp.clone().try_connect(node_addr, node_id).await {
- error!("{}\n{}", connect_error_message(node_addr, node_id), e);
+ error!("{}", connect_error_message(node_addr, node_id, e));
}
});
}
@@ -871,6 +868,10 @@ async fn resolve_peers(peers: &[String]) -> Vec<(NodeID, SocketAddr)> {
ret
}
-fn connect_error_message(addr: SocketAddr, pubkey: ed25519::PublicKey) -> String {
- format!("Error establishing RPC connection to remote node: {}@{}.\nThis can happen if the remote node is not reachable on the network, but also if the two nodes are not configured with the same rpc_secret", hex::encode(pubkey), addr)
+fn connect_error_message(
+ addr: SocketAddr,
+ pubkey: ed25519::PublicKey,
+ e: netapp::error::Error,
+) -> String {
+ format!("Error establishing RPC connection to remote node: {}@{}.\nThis can happen if the remote node is not reachable on the network, but also if the two nodes are not configured with the same rpc_secret.\n{}", hex::encode(pubkey), addr, e)
}