warning instead of panic for missing nodes by id
This commit is contained in:
@@ -0,0 +1 @@
|
||||
edition = "2024"
|
||||
+14
-4
@@ -256,7 +256,7 @@ pub mod scores {
|
||||
.get(0)
|
||||
.expect("empty nodes list for a visible way is possible??")
|
||||
.to_string();
|
||||
Some(node_id_location(node_id, client).await)
|
||||
node_id_location(node_id, client).await
|
||||
} else {
|
||||
let version =
|
||||
version_attr(attrs.clone()).expect("version is expected to be present");
|
||||
@@ -399,7 +399,7 @@ pub mod scores {
|
||||
}
|
||||
}
|
||||
|
||||
async fn node_id_location(id: String, client: &Client) -> geo_types::Point {
|
||||
async fn node_id_location(id: String, client: &Client) -> Option<geo_types::Point> {
|
||||
match network::get_node(id.clone(), client).await {
|
||||
Ok(res) => {
|
||||
let reader = EventReader::from_str(&res);
|
||||
@@ -413,13 +413,23 @@ pub mod scores {
|
||||
}
|
||||
false
|
||||
});
|
||||
if nodes.len() < 1 {
|
||||
println!(
|
||||
"Warning: node with id {} is not found, result can be impacted",
|
||||
id
|
||||
);
|
||||
return None;
|
||||
}
|
||||
let node_attributes = &nodes
|
||||
.get(0)
|
||||
.expect("empty node list is not expected at this point")
|
||||
.1;
|
||||
node_location(node_attributes)
|
||||
Some(node_location(node_attributes))
|
||||
}
|
||||
Err(e) => {
|
||||
println!("error {e:?}");
|
||||
None
|
||||
}
|
||||
Err(e) => panic!("error {e:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user