Improve wallet + node API Comms error logging (#2472)

* make wallet+node communication errors more verbose

* rustfmt
This commit is contained in:
Yeastplume
2019-01-25 12:12:50 +00:00
committed by GitHub
parent dd1a24dcbc
commit a97ab376cb
6 changed files with 61 additions and 35 deletions
+9 -4
View File
@@ -48,10 +48,15 @@ impl WalletCommAdapter for HTTPWalletCommAdapter {
let url = format!("{}/v1/wallet/foreign/receive_tx", dest);
debug!("Posting transaction slate to {}", url);
let res = api::client::post(url.as_str(), None, slate).context(
ErrorKind::ClientCallback("Posting transaction slate (is recipient listening?)"),
)?;
Ok(res)
let res = api::client::post(url.as_str(), None, slate);
match res {
Err(e) => {
let report = format!("Posting transaction slate (is recipient listening?): {}", e);
error!("{}", report);
Err(ErrorKind::ClientCallback(report).into())
}
Ok(r) => Ok(r),
}
}
fn send_tx_async(&self, _dest: &str, _slate: &Slate) -> Result<(), Error> {
+10 -2
View File
@@ -291,7 +291,11 @@ impl WalletCommAdapter for KeybaseWalletCommAdapter {
// Send original slate to recipient with the SLATE_NEW topic
match send(slate, addr, SLATE_NEW, TTL) {
true => (),
false => return Err(ErrorKind::ClientCallback("Posting transaction slate"))?,
false => {
return Err(ErrorKind::ClientCallback(
"Posting transaction slate".to_owned(),
))?
}
}
info!(
"tx request has been sent to @{}, tx uuid: {}",
@@ -300,7 +304,11 @@ impl WalletCommAdapter for KeybaseWalletCommAdapter {
// Wait for response from recipient with SLATE_SIGNED topic
match poll(TTL as u64, addr) {
Some(slate) => return Ok(slate),
None => return Err(ErrorKind::ClientCallback("Receiving reply from recipient"))?,
None => {
return Err(ErrorKind::ClientCallback(
"Receiving reply from recipient".to_owned(),
))?
}
}
}