Skip to content

Commit

Permalink
Clarify errors in main() coming from the governance canister client. (
Browse files Browse the repository at this point in the history
#232)

I spent 10 minutes trying to grep for the error, to no avail.  When I
had to spend another 5 minutes adding `panic()`s to the code in order
to suss this one out, I decided to do something about it.
  • Loading branch information
DFINITYManu committed Mar 6, 2024
1 parent bdd1208 commit e086a17
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions rs/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ async fn main() -> Result<(), anyhow::Error> {
let mut cli_opts = cli::Opts::parse();
let mut cmd = cli::Opts::command();

let governance_canister_v = governance_canister_version(cli_opts.network.get_url()).await?;
let governance_canister_v = match governance_canister_version(cli_opts.network.get_url()).await {
Ok(c) => c,
Err(e) => {
return Err(anyhow::anyhow!(
"While determining the governance canister version: {}",
e
))
}
};

let governance_canister_version = governance_canister_v.stringified_hash;

let target_network = cli_opts.network.clone();
Expand All @@ -52,9 +61,10 @@ async fn main() -> Result<(), anyhow::Error> {
.expect("failed")
});
});

let srv = rx.recv().unwrap();

ic_admin::with_ic_admin(governance_canister_version.into(), async {
let r = ic_admin::with_ic_admin(governance_canister_version.into(), async {

// Start of actually doing stuff with commands.
if cli_opts.network == Network::Staging {
Expand Down Expand Up @@ -303,11 +313,11 @@ async fn main() -> Result<(), anyhow::Error> {
}
}
})
.await?;
.await;

srv.stop(false).await;

Ok(())
r
}

// Construct MinNakamotoCoefficients from an array (slice) of ["key=value"], and
Expand Down

0 comments on commit e086a17

Please sign in to comment.