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/repo_ref.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/lib/repo_ref.rs') diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs index 84de185..05234e2 100644 --- a/src/lib/repo_ref.rs +++ b/src/lib/repo_ref.rs @@ -95,7 +95,7 @@ impl TryFrom for RepoRef { for pk in maintainers { r.maintainers.push( nostr_sdk::prelude::PublicKey::from_str(&pk) - .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) + .context(format!("failed to convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) .context("invalid repository event")?, ); } @@ -421,8 +421,9 @@ pub fn extract_pks(pk_strings: Vec) -> Result> { let mut pks: Vec = vec![]; for s in pk_strings { pks.push( - nostr_sdk::prelude::PublicKey::from_bech32(s.clone()) - .context(format!("cannot convert {s} into a valid nostr public key"))?, + nostr_sdk::prelude::PublicKey::from_bech32(s.clone()).context(format!( + "failed to convert {s} into a valid nostr public key" + ))?, ); } Ok(pks) @@ -441,15 +442,15 @@ pub fn save_repo_config_to_yaml( .write(true) .truncate(true) .open(path) - .context("cannot open maintainers.yaml file with write and truncate options")? + .context("failed to open maintainers.yaml file with write and truncate options")? } else { - std::fs::File::create(path).context("cannot create maintainers.yaml file")? + std::fs::File::create(path).context("failed to create maintainers.yaml file")? }; let mut maintainers_npubs = vec![]; for m in maintainers { maintainers_npubs.push( m.to_bech32() - .context("cannot convert public key into npub")?, + .context("failed to convert public key into npub")?, ); } serde_yaml::to_writer( @@ -460,7 +461,7 @@ pub fn save_repo_config_to_yaml( relays, }, ) - .context("cannot write maintainers to maintainers.yaml file serde_yaml") + .context("failed to write maintainers to maintainers.yaml file serde_yaml") } #[cfg(test)] -- cgit v1.2.3