Fail gracefully when keypair file is unreadable

This commit is contained in:
Michael Vines 2018-07-13 09:31:59 -07:00
parent fa1cdaa91a
commit 18e6ff4167
1 changed files with 7 additions and 1 deletions

View File

@ -155,7 +155,13 @@ fn parse_args() -> Result<WalletConfig, Box<error::Error>> {
path.extend(&[".config", "solana", "id.json"]);
path.to_str().unwrap()
};
let id = read_keypair(id_path).expect("client keypair");
let id = read_keypair(id_path).or_else(|err| {
display_actions();
Err(WalletError::BadParameter(format!(
"{}: Unable to open keypair file: {}",
err, id_path
)))
})?;
let mut drone_addr = leader.contact_info.tpu;
drone_addr.set_port(9900);