mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-31 16:40:22 +00:00
working_copy: use #[from]
to slightly simplify error handling
This commit is contained in:
parent
ac82ad892e
commit
899325e94e
1 changed files with 5 additions and 9 deletions
|
@ -199,7 +199,7 @@ pub enum SnapshotError {
|
|||
#[error("Symlink {path} target is not valid UTF-8")]
|
||||
InvalidUtf8SymlinkTarget { path: PathBuf, target: PathBuf },
|
||||
#[error("Internal backend error: {0:?}")]
|
||||
InternalBackendError(BackendError),
|
||||
InternalBackendError(#[from] BackendError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error, PartialEq, Eq)]
|
||||
|
@ -213,7 +213,7 @@ pub enum CheckoutError {
|
|||
#[error("Concurrent checkout")]
|
||||
ConcurrentCheckout,
|
||||
#[error("Internal error: {0:?}")]
|
||||
InternalBackendError(BackendError),
|
||||
InternalBackendError(#[from] BackendError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error, PartialEq, Eq)]
|
||||
|
@ -223,7 +223,7 @@ pub enum ResetError {
|
|||
#[error("Current checkout not found")]
|
||||
SourceNotFound,
|
||||
#[error("Internal error: {0:?}")]
|
||||
InternalBackendError(BackendError),
|
||||
InternalBackendError(#[from] BackendError),
|
||||
}
|
||||
|
||||
impl TreeState {
|
||||
|
@ -335,9 +335,7 @@ impl TreeState {
|
|||
path: disk_path.to_path_buf(),
|
||||
err,
|
||||
})?;
|
||||
self.store
|
||||
.write_file(path, &mut Box::new(file))
|
||||
.map_err(SnapshotError::InternalBackendError)
|
||||
Ok(self.store.write_file(path, &mut Box::new(file))?)
|
||||
}
|
||||
|
||||
fn write_symlink_to_store(
|
||||
|
@ -358,9 +356,7 @@ impl TreeState {
|
|||
path: disk_path.to_path_buf(),
|
||||
target: target.clone(),
|
||||
})?;
|
||||
self.store
|
||||
.write_symlink(path, str_target)
|
||||
.map_err(SnapshotError::InternalBackendError)
|
||||
Ok(self.store.write_symlink(path, str_target)?)
|
||||
}
|
||||
|
||||
/// Look for changes to the working copy. If there are any changes, create
|
||||
|
|
Loading…
Reference in a new issue