Skip to content

Commit

Permalink
unify error
Browse files Browse the repository at this point in the history
  • Loading branch information
katiemckeon committed Jan 28, 2025
1 parent 7b76e67 commit 3473a4b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cli/src/bin/cargo-sindri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ pub enum Commands {
},
}

fn handle_circuit_error(message: &str) -> ! {
eprintln!("{}", style("Circuit creation failed ❌").bold());
eprintln!("{}", style(message).red());
std::process::exit(1);
}

fn main() {
let Cargo::Sindri(args) = Cargo::parse();

Expand Down Expand Up @@ -80,9 +86,7 @@ fn main() {
parts.next().unwrap_or_default().to_string(),
))
} else {
eprintln!("{}", style("Circuit creation failed ❌").bold());
eprintln!("{}", style(format!("\"{pair}\" is not a valid metadata pair.")).red());
std::process::exit(1);
handle_circuit_error(&format!("\"{pair}\" is not a valid metadata pair."));
}
})
.collect::<HashMap<String, String>>()
Expand All @@ -104,16 +108,12 @@ fn main() {
println!("• Circuit UUID: {}", style(uuid).cyan());
println!("• Identifier: {}", style(format!("{}/{}:{}", team, project_name, first_tag)).cyan());
} else {
eprintln!("{}", style("Circuit creation failed ❌").bold());
eprintln!("{}", style(response.error().unwrap_or_default()).red());
std::process::exit(1);
handle_circuit_error(&response.error().unwrap_or_default())
}
}
Err(e) => {
eprintln!("{}", style("Circuit creation failed ❌").bold());
eprintln!("{}", style(e).red());
std::process::exit(1);
}
handle_circuit_error(&e.to_string())
}
}
}
}
Expand Down

0 comments on commit 3473a4b

Please sign in to comment.