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/bin/ngit/sub_commands/list.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/bin/ngit/sub_commands/list.rs') diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs index 7717dce..1e8ecc4 100644 --- a/src/bin/ngit/sub_commands/list.rs +++ b/src/bin/ngit/sub_commands/list.rs @@ -24,7 +24,7 @@ use crate::{ #[allow(clippy::too_many_lines)] pub async fn launch() -> Result<()> { - let git_repo = Repo::discover().context("cannot find a git repository")?; + let git_repo = Repo::discover().context("failed to find a git repository")?; let git_repo_path = git_repo.get_path()?; // TODO: check for empty repo @@ -179,7 +179,7 @@ pub async fn launch() -> Result<()> { } let cover_letter = event_to_cover_letter(proposals_for_status[selected_index]) - .context("cannot extract proposal details from proposal root event")?; + .context("failed to extract proposal details from proposal root event")?; let commits_events: Vec = get_all_proposal_patch_events_from_cache( git_repo_path, @@ -195,7 +195,7 @@ pub async fn launch() -> Result<()> { PromptConfirmParms::default() .with_default(true) .with_prompt( - "cannot find any patches on this proposal. choose another proposal?", + "failed to find any patches on this proposal. choose another proposal?", ), )? { continue; @@ -275,7 +275,7 @@ pub async fn launch() -> Result<()> { )?, "parent-commit", )?) - .context("cannot get valid parent commit id from patch")?; + .context("failed to get valid parent commit id from patch")?; let (main_branch_name, master_tip) = git_repo.get_main_or_master_branch()?; @@ -305,9 +305,9 @@ pub async fn launch() -> Result<()> { &get_commit_id_from_patch(most_recent_proposal_patch_chain.first().context( "there should be at least one patch as we have already checked for this", )?) - .context("cannot get valid commit_id from patch")?, + .context("failed to get valid commit_id from patch")?, ) - .context("cannot get valid commit_id from patch")?; + .context("failed to get valid commit_id from patch")?; let (_, proposal_behind_main) = git_repo.get_commits_ahead_behind(&master_tip, &proposal_base_commit)?; @@ -332,7 +332,7 @@ pub async fn launch() -> Result<()> { &cover_letter.get_branch_name()?, most_recent_proposal_patch_chain, ) - .context("cannot apply patch chain")?; + .context("failed to apply patch chain")?; println!( "checked out proposal as '{}' branch", @@ -427,7 +427,7 @@ pub async fn launch() -> Result<()> { &cover_letter.get_branch_name()?, most_recent_proposal_patch_chain, ) - .context("cannot apply patch chain")?; + .context("failed to apply patch chain")?; println!( "checked out proposal branch and applied {} appendments ({} ahead {} behind '{main_branch_name}')", &index, @@ -484,7 +484,7 @@ pub async fn launch() -> Result<()> { &cover_letter.get_branch_name()?, most_recent_proposal_patch_chain, ) - .context("cannot apply patch chain")?; + .context("failed to apply patch chain")?; println!( "checked out new version of proposal ({} ahead {} behind '{main_branch_name}'), replacing old version ({} ahead {} behind '{main_branch_name}')", chain_length, @@ -517,7 +517,9 @@ pub async fn launch() -> Result<()> { else if git_repo.ancestor_of(&local_branch_tip, &proposal_tip)? { let (local_ahead_of_proposal, _) = git_repo .get_commits_ahead_behind(&proposal_tip, &local_branch_tip) - .context("cannot get commits ahead behind for propsal_top and local_branch_tip")?; + .context( + "failed to get commits ahead behind for propsal_top and local_branch_tip", + )?; println!( "local proposal branch exists with {} unpublished commits on top of the most up-to-date version of the proposal ({} ahead {} behind '{main_branch_name}')", @@ -624,7 +626,7 @@ pub async fn launch() -> Result<()> { &cover_letter.get_branch_name()?, most_recent_proposal_patch_chain, ) - .context("cannot apply patch chain")?; + .context("failed to apply patch chain")?; git_repo.checkout(&cover_letter.get_branch_name()?)?; println!( @@ -715,7 +717,7 @@ fn save_patches_to_dir(mut patches: Vec, git_repo: &Repo) -> Resul fn check_clean(git_repo: &Repo) -> Result<()> { if git_repo.has_outstanding_changes()? { bail!( - "cannot pull proposal branch when repository is not clean. discard or stash (un)staged changes and try again." + "failed to pull proposal branch when repository is not clean. discard or stash (un)staged changes and try again." ); } Ok(()) -- cgit v1.2.3