From 0e09d53ce6993bc64d98d163d3366d6155d19259 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 11 Oct 2023 12:30:26 -0700 Subject: [PATCH] working copy: make some reset errors less specific Same reasoning as the previous commits. --- lib/src/local_working_copy.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index 21d835592..5262edf87 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -395,8 +395,12 @@ pub enum ResetError { }, #[error("Internal error: {0}")] InternalBackendError(#[from] BackendError), - #[error(transparent)] - TreeStateError(#[from] TreeStateError), + #[error("{message}: {err:?}")] + Other { + message: String, + #[source] + err: Box, + }, } struct DirectoryToVisit { @@ -1635,7 +1639,13 @@ impl LockedLocalWorkingCopy<'_> { } pub fn reset(&mut self, new_tree: &MergedTree) -> Result<(), ResetError> { - self.wc.tree_state_mut()?.reset(new_tree)?; + self.wc + .tree_state_mut() + .map_err(|err| ResetError::Other { + message: "Failed to read the working copy state".to_string(), + err: err.into(), + })? + .reset(new_tree)?; self.tree_state_dirty = true; Ok(()) }