Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update get_node error reporting #129

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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