From a0593e3aa9b19b9ca3c3881cbe0d9d207fe46d2c Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 26 Nov 2024 07:48:30 +0000 Subject: refactor: err msgs 'cannot' > 'failed to' in nearly all cases 'cannot' was used when an action was tried and failed. 'failed to' is strictly better because: * just because the action didn't work that time doesnt mean it cannot work * it is better at drawing the users attention to a problem --- src/lib/login/existing.rs | 8 +++++--- src/lib/login/fresh.rs | 2 +- src/lib/login/mod.rs | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/lib/login') diff --git a/src/lib/login/existing.rs b/src/lib/login/existing.rs index e388a34..342f792 100644 --- a/src/lib/login/existing.rs +++ b/src/lib/login/existing.rs @@ -81,13 +81,13 @@ fn get_signer_info( break; } } - result.context("cannot get or find signer info in cli arguments, local git config or global git config")? + result.context("failed to get or find signer info in cli arguments, local git config or global git config")? } Some(SignerInfoSource::CommandLineArguments) => { if let Some(signer_info) = signer_info { (signer_info.clone(), SignerInfoSource::CommandLineArguments) } else { - bail!("cannot get signer from cli signer arguments because none were specified") + bail!("failed to get signer from cli signer arguments because none were specified") } } Some(SignerInfoSource::GitLocal) => { @@ -169,7 +169,9 @@ async fn get_signer( password.clone() } else { if !prompt_for_ncryptsec_password { - bail!("cannot login without prompts a nsec is encrypted with a password"); + bail!( + "failed to login without prompts a nsec is encrypted with a password" + ); } Interactor::default() .password(PromptPasswordParms::default().with_prompt("password")) diff --git a/src/lib/login/fresh.rs b/src/lib/login/fresh.rs index 194f638..62622a8 100644 --- a/src/lib/login/fresh.rs +++ b/src/lib/login/fresh.rs @@ -627,7 +627,7 @@ fn silently_save_to_git_config( let git_repo = if global { &None } else if git_repo.is_none() { - bail!("cannot update local git config wihout git_repo object") + bail!("failed to update local git config wihout git_repo object") } else { git_repo }; diff --git a/src/lib/login/mod.rs b/src/lib/login/mod.rs index d2725e7..00dbb17 100644 --- a/src/lib/login/mod.rs +++ b/src/lib/login/mod.rs @@ -61,12 +61,12 @@ fn print_logged_in_as( source: &SignerInfoSource, ) -> Result<()> { if !offline_mode && user_ref.metadata.created_at.eq(&Timestamp::from(0)) { - eprintln!("cannot find profile..."); + eprintln!("failed to find profile..."); } else if !offline_mode && user_ref.metadata.name.eq(&user_ref.public_key.to_bech32()?) { - eprintln!("cannot extract account name from account metadata..."); + eprintln!("failed to extract account name from account metadata..."); } else if !offline_mode && user_ref.relays.created_at.eq(&Timestamp::from(0)) { eprintln!( - "cannot find your relay list. consider using another nostr client to create one to enhance your nostr experience." + "failed to find your relay list. consider using another nostr client to create one to enhance your nostr experience." ); } eprintln!( -- cgit v1.2.3