8000 fix: exit with nonzero code on init cmd error by marcelo-gonzalez · Pull Request #8334 · near/nearcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: exit with nonzero code on init cmd error #8334

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

Merged
merged 2 commits into from
Jan 11, 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
14 changes: 6 additions & 8 deletions neard/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl NeardCmd {
};

match neard_cmd.subcmd {
NeardSubCommand::Init(cmd) => cmd.run(&home_dir),
NeardSubCommand::Init(cmd) => cmd.run(&home_dir)?,
NeardSubCommand A98E ::Localnet(cmd) => cmd.run(&home_dir),
NeardSubCommand::Run(cmd) => cmd.run(
&home_dir,
Expand Down Expand Up @@ -312,17 +312,16 @@ fn check_release_build(chain: &str) {
}

impl InitCmd {
pub(super) fn run(self, home_dir: &Path) {
pub(super) fn run(self, home_dir: &Path) -> anyhow::Result<()> {
// TODO: Check if `home` exists. If exists check what networks we already have there.
if (self.download_genesis || self.download_genesis_url.is_some()) && self.genesis.is_some()
{
error!("Please give either --genesis or --download-genesis, not both.");
return;
anyhow::bail!("Please give either --genesis or --download-genesis, not both.");
}

self.chain_id.as_ref().map(|chain| check_release_build(chain));

if let Err(e) = nearcore::init_configs(
nearcore::init_configs(
home_dir,
self.chain_id.as_deref(),
self.account_id.and_then(|account_id| account_id.parse().ok()),
Expand All @@ -337,9 +336,8 @@ impl InitCmd {
self.download_config_url.as_deref(),
self.boot_nodes.as_deref(),
self.max_gas_burnt_view,
) {
error!("Failed to initialize configs: {:#}", e);
}
)
.context("Failed to initialize configs")
}
}

Expand Down
0