From 10343876fa5227b262a66ddd598da7c5d792e112 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 27 Oct 2022 23:15:18 -0700 Subject: [PATCH] cli: include message from `GitExportError` to user I'm going to add other error variants for when we fail to read/write to disk, and I don't think we need to have a custom message for each in the CLI crate. It's easier to pass along the message from the lib crate. (`ConflictedBranch`, on the other hand, is an expected error so I think we should continue to let let the CLI crate define the error message for it.) --- lib/src/git.rs | 2 +- src/cli_util.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/git.rs b/lib/src/git.rs index d01d1b945..a9d6440e7 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -166,7 +166,7 @@ pub fn import_refs( pub enum GitExportError { #[error("Cannot export conflicted branch '{0}'")] ConflictedBranch(String), - #[error("Unexpected git error when exporting refs: {0}")] + #[error("Git error: {0}")] InternalGitError(#[from] git2::Error), } diff --git a/src/cli_util.rs b/src/cli_util.rs index a45e56f8f..69b297e04 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -169,7 +169,7 @@ impl From for CommandError { GitExportError::ConflictedBranch(branch_name) => { user_error(format!("Cannot export conflicted branch '{branch_name}'")) } - GitExportError::InternalGitError(err) => CommandError::InternalError(format!( + err => CommandError::InternalError(format!( "Failed to export refs to underlying Git repo: {err}" )), }