From b0409f4927638a9558e6a96982e8acb3c7916246 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Mon, 6 Nov 2023 23:39:19 +0100 Subject: [PATCH] Update get_node error reporting (#129) --- crates/orchestrator/src/network.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/orchestrator/src/network.rs b/crates/orchestrator/src/network.rs index 27ddc232a..20edbd831 100644 --- a/crates/orchestrator/src/network.rs +++ b/crates/orchestrator/src/network.rs @@ -182,13 +182,22 @@ impl Network { // deregister and stop the collator? // remove_parachain() - pub fn get_node(&self, node_name: impl Into) -> Result<&NetworkNode, anyhow::Error> { - let node_name = node_name.into(); - if let Some(node) = self.nodes_by_name.get(&node_name) { - Ok(node) - } else { - Err(anyhow::anyhow!("can't find the node!")) + pub fn get_node(&self, name: impl Into) -> Result<&NetworkNode, anyhow::Error> { + let name = &name.into(); + if let Some(node) = self.nodes_by_name.get(name) { + return Ok(node); } + + let list = self + .nodes_by_name + .keys() + .cloned() + .collect::>() + .join(", "); + + Err(anyhow::anyhow!( + "can't find node with name: {name:?}, should be one of {list}" + )) } pub fn nodes(&self) -> Vec<&NetworkNode> {