From 18e6ff41674269fa6dfb2a48a6f7d03209710633 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 13 Jul 2018 09:31:59 -0700 Subject: [PATCH] Fail gracefully when keypair file is unreadable --- src/bin/wallet.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bin/wallet.rs b/src/bin/wallet.rs index cb48d32751a40a..c843239e273906 100644 --- a/src/bin/wallet.rs +++ b/src/bin/wallet.rs @@ -155,7 +155,13 @@ fn parse_args() -> Result> { 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);