mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-13 08:47:17 +03:00
refactor: error display
This commit is contained in:
parent
ba6b9c4e41
commit
a0e38b9f5e
@ -179,6 +179,13 @@ create_messages!(
|
||||
help: None,
|
||||
}
|
||||
|
||||
@backtraced
|
||||
failed_to_parse_private_key {
|
||||
args: (error: impl Display),
|
||||
msg: format!("Failed to parse private key.\nSnarkVM Error: {error}"),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@backtraced
|
||||
failed_to_execute_account {
|
||||
args: (error: impl Display),
|
||||
|
@ -89,9 +89,17 @@ impl Command for Account {
|
||||
let priv_key = match discreet {
|
||||
true => {
|
||||
let private_key_input = rpassword::prompt_password("Please enter your private key: ").unwrap();
|
||||
FromStr::from_str(&private_key_input).map_err(CliError::failed_to_execute_account)?
|
||||
FromStr::from_str(&private_key_input).map_err(CliError::failed_to_parse_private_key)?
|
||||
}
|
||||
false => private_key.expect("PRIVATE_KEY shouldn't be empty when --discreet is false"),
|
||||
false => match private_key {
|
||||
Some(private_key) => private_key,
|
||||
None => {
|
||||
return Err(CliError::failed_to_execute_account(
|
||||
"PRIVATE_KEY shouldn't be empty when --discreet is false",
|
||||
)
|
||||
.into())
|
||||
}
|
||||
},
|
||||
};
|
||||
// Derive the view key and address and print to stdout.
|
||||
print_keys(priv_key, discreet)?;
|
||||
|
Loading…
Reference in New Issue
Block a user