From 4541e00eacbbeda8d697a7733912e8f3da548493 Mon Sep 17 00:00:00 2001 From: lunar-mining Date: Thu, 19 May 2022 12:09:47 +0200 Subject: [PATCH] dnetview: propagate errors more descriptively --- bin/dnetview/src/main.rs | 10 ++++------ bin/dnetview/src/view.rs | 4 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/dnetview/src/main.rs b/bin/dnetview/src/main.rs index d6848f125..45c9449fc 100644 --- a/bin/dnetview/src/main.rs +++ b/bin/dnetview/src/main.rs @@ -43,10 +43,8 @@ struct DnetView { impl DnetView { async fn new(url: Url, name: String) -> Result { - match RpcClient::new(url).await { - Ok(rpc_client) => return Ok(Self { name, rpc_client }), - Err(e) => return Err(Error::OperationFailed), - } + let rpc_client = RpcClient::new(url).await?; + Ok(Self { name, rpc_client }) } // --> {"jsonrpc": "2.0", "method": "ping", "params": [], "id": 42} @@ -58,11 +56,11 @@ impl DnetView { //--> {"jsonrpc": "2.0", "method": "poll", "params": [], "id": 42} // <-- {"jsonrpc": "2.0", "result": {"nodeID": [], "nodeinfo" [], "id": 42} - async fn get_info(&self) -> Result { + async fn get_info(&self) -> DnetViewResult { let req = jsonrpc::request(json!("get_info"), json!([])); match self.rpc_client.request(req).await { Ok(req) => return Ok(req), - Err(_e) => return Err(Error::OperationFailed), + Err(e) => return Err(DnetViewError::Darkfi(e)), } } } diff --git a/bin/dnetview/src/view.rs b/bin/dnetview/src/view.rs index f61195b61..a0e86be6a 100644 --- a/bin/dnetview/src/view.rs +++ b/bin/dnetview/src/view.rs @@ -17,7 +17,7 @@ use crate::{ error::{DnetViewError, DnetViewResult}, model::{NodeInfo, SelectableObject}, }; -//use log::debug; +use log::debug; #[derive(Debug)] pub struct View { @@ -99,6 +99,8 @@ impl View { // remove any duplicates id_list.dedup(); + //debug!("ID LIST {:?}", id_list); + //debug!("ACTIVE ID LIST {:?}", self.active_ids.ids); if id_list.is_empty() { // we have not received any data Ok(())