From ef126a6a922785a9020e20f3d65b918b80dcd4d4 Mon Sep 17 00:00:00 2001 From: Alexander Simmerl Date: Tue, 14 Sep 2021 23:27:40 +1000 Subject: [PATCH] rad-clib: Avoid unwrap with transparent error Will give callers more control over the handling of that error case, the author expects this to be an oversight of the original implementation. Signed-off-by: Alexander Simmerl --- rad-clib/src/keys.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rad-clib/src/keys.rs b/rad-clib/src/keys.rs index 6b59aa3df..6a4256d91 100644 --- a/rad-clib/src/keys.rs +++ b/rad-clib/src/keys.rs @@ -22,7 +22,7 @@ use librad::{ IntoSecretKeyError, SomeSigner, }, - git::storage::ReadOnly, + git::storage::{self, ReadOnly}, profile::Profile, PublicKey, SecretKey, @@ -37,6 +37,8 @@ pub enum Error { File(#[from] file::Error, IntoSecretKeyError>), #[error(transparent)] SshConnect(#[from] ssh::error::Connect), + #[error(transparent)] + StorageInit(#[from] storage::read::error::Init), } /// Create a [`Prompt`] for unlocking the key storage. @@ -79,7 +81,7 @@ pub async fn signer_ssh(profile: &Profile) -> Result where S: ClientStream + Unpin + 'static, { - let storage = ReadOnly::open(profile.paths()).unwrap(); + let storage = ReadOnly::open(profile.paths())?; let peer_id = storage.peer_id(); let agent = SshAgent::new((**peer_id).into()); let signer = agent.connect::().await?;