Skip to content

Commit

Permalink
Update get_node error reporting (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou authored Nov 6, 2023
1 parent 119a0dd commit b0409f4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions crates/orchestrator/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,22 @@ impl<T: FileSystem> Network<T> {
// deregister and stop the collator?
// remove_parachain()

pub fn get_node(&self, node_name: impl Into<String>) -> 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<String>) -> 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::<Vec<_>>()
.join(", ");

Err(anyhow::anyhow!(
"can't find node with name: {name:?}, should be one of {list}"
))
}

pub fn nodes(&self) -> Vec<&NetworkNode> {
Expand Down

0 comments on commit b0409f4

Please sign in to comment.