mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
dnetview: propagate errors more descriptively
This commit is contained in:
@@ -43,10 +43,8 @@ struct DnetView {
|
||||
|
||||
impl DnetView {
|
||||
async fn new(url: Url, name: String) -> Result<Self> {
|
||||
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<Value> {
|
||||
async fn get_info(&self) -> DnetViewResult<Value> {
|
||||
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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user