From d2d6f4762486e8395fffec566e53cc858c52af6c Mon Sep 17 00:00:00 2001
From: Michael Vines <mvines@gmail.com>
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<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);