warning instead of panic for missing nodes by id

This commit is contained in:
2026-11-12 14:33:58 -08:00
parent 94685621b2
commit 09e6bc4f93
2 changed files with 15 additions and 4 deletions
+1
View File
@@ -0,0 +1 @@
edition = "2024"
+14 -4
View File
@@ -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:?}"),
}
}
}