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

chore(cast): improve cast wallet new #7021

Merged
merged 1 commit into from
Feb 6, 2024
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
9 changes: 8 additions & 1 deletion crates/cast/bin/cmd/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ impl WalletSubcommands {

let mut json_values = if json { Some(vec![]) } else { None };
if let Some(path) = path {
let path = dunce::canonicalize(path)?;
let path = match dunce::canonicalize(path.clone()) {
Ok(path) => path,
// If the path doesn't exist, it will fail to be canonicalized,
// so we attach more context to the error message.
Err(e) => {
eyre::bail!("If you specified a directory, please make sure it exists, or create it before running `cast wallet new <DIR>`.\n{path} is not a directory.\nError: {}", e);
}
};
if !path.is_dir() {
// we require path to be an existing directory
eyre::bail!("`{}` is not a directory", path.display());
Expand Down
Loading