upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib/repo_ref.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-11-26 07:48:30 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-11-26 12:26:47 +0000
commita0593e3aa9b19b9ca3c3881cbe0d9d207fe46d2c (patch)
tree3482e7c558eff09cc91604ad6ddcd02cf2c94699 /src/lib/repo_ref.rs
parent1332c625b75fce616e06b415c99a068bc45c8210 (diff)
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
Diffstat (limited to 'src/lib/repo_ref.rs')
-rw-r--r--src/lib/repo_ref.rs15
1 files changed, 8 insertions, 7 deletions
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<nostr::Event> for RepoRef {
95 for pk in maintainers { 95 for pk in maintainers {
96 r.maintainers.push( 96 r.maintainers.push(
97 nostr_sdk::prelude::PublicKey::from_str(&pk) 97 nostr_sdk::prelude::PublicKey::from_str(&pk)
98 .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) 98 .context(format!("failed to convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format"))
99 .context("invalid repository event")?, 99 .context("invalid repository event")?,
100 ); 100 );
101 } 101 }
@@ -421,8 +421,9 @@ pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<PublicKey>> {
421 let mut pks: Vec<PublicKey> = vec![]; 421 let mut pks: Vec<PublicKey> = vec![];
422 for s in pk_strings { 422 for s in pk_strings {
423 pks.push( 423 pks.push(
424 nostr_sdk::prelude::PublicKey::from_bech32(s.clone()) 424 nostr_sdk::prelude::PublicKey::from_bech32(s.clone()).context(format!(
425 .context(format!("cannot convert {s} into a valid nostr public key"))?, 425 "failed to convert {s} into a valid nostr public key"
426 ))?,
426 ); 427 );
427 } 428 }
428 Ok(pks) 429 Ok(pks)
@@ -441,15 +442,15 @@ pub fn save_repo_config_to_yaml(
441 .write(true) 442 .write(true)
442 .truncate(true) 443 .truncate(true)
443 .open(path) 444 .open(path)
444 .context("cannot open maintainers.yaml file with write and truncate options")? 445 .context("failed to open maintainers.yaml file with write and truncate options")?
445 } else { 446 } else {
446 std::fs::File::create(path).context("cannot create maintainers.yaml file")? 447 std::fs::File::create(path).context("failed to create maintainers.yaml file")?
447 }; 448 };
448 let mut maintainers_npubs = vec![]; 449 let mut maintainers_npubs = vec![];
449 for m in maintainers { 450 for m in maintainers {
450 maintainers_npubs.push( 451 maintainers_npubs.push(
451 m.to_bech32() 452 m.to_bech32()
452 .context("cannot convert public key into npub")?, 453 .context("failed to convert public key into npub")?,
453 ); 454 );
454 } 455 }
455 serde_yaml::to_writer( 456 serde_yaml::to_writer(
@@ -460,7 +461,7 @@ pub fn save_repo_config_to_yaml(
460 relays, 461 relays,
461 }, 462 },
462 ) 463 )
463 .context("cannot write maintainers to maintainers.yaml file serde_yaml") 464 .context("failed to write maintainers to maintainers.yaml file serde_yaml")
464} 465}
465 466
466#[cfg(test)] 467#[cfg(test)]