diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..0fb71e6 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +edition = "2024" \ No newline at end of file diff --git a/src/osm.rs b/src/osm.rs index 13d3421..4423803 100644 --- a/src/osm.rs +++ b/src/osm.rs @@ -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 { 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:?}"), } } }