Improve error message when unable to read a file (#6978)

This commit is contained in:
Michael Vines 2019-11-15 10:39:05 -07:00 committed by GitHub
parent 59413b3124
commit 892ca196f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -33,6 +33,7 @@ pub enum AccountFileFormat {
fn pubkey_from_file(key_file: &str) -> Result<Pubkey, Box<dyn error::Error>> {
read_pubkey_file(key_file)
.or_else(|_| read_keypair_file(key_file).map(|keypair| keypair.pubkey()))
.map_err(|err| format!("Failed to read {}: {}", key_file, err).into())
}
fn pubkey_from_str(key_str: &str) -> Result<Pubkey, Box<dyn error::Error>> {