Skip to content

Commit

Permalink
chore(cast): improve cast wallet new (#7021)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir authored Feb 6, 2024
1 parent 0b63398 commit 865a0d1
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 865a0d1

Please sign in to comment.