Skip to content

Commit

Permalink
rad-clib: Avoid unwrap with transparent error
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xla committed Sep 14, 2021
1 parent 482e794 commit ef126a6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rad-clib/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use librad::{
IntoSecretKeyError,
SomeSigner,
},
git::storage::ReadOnly,
git::storage::{self, ReadOnly},
profile::Profile,
PublicKey,
SecretKey,
Expand All @@ -37,6 +37,8 @@ pub enum Error {
File(#[from] file::Error<SecretBoxError<std::io::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.
Expand Down Expand Up @@ -79,7 +81,7 @@ pub async fn signer_ssh<S>(profile: &Profile) -> Result<BoxedSigner, Error>
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::<S>().await?;
Expand Down

0 comments on commit ef126a6

Please sign in to comment.