summaryrefslogtreecommitdiff
path: root/src/fsentry.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-24 08:18:56 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-29 10:51:31 +0300
commit80ae98bf87c57aa361a13c3dd925455fb67e3f03 (patch)
treeaca3860996a6ebd622802d6a41493008189203ab /src/fsentry.rs
parentbf645f3645fd2ee57495eafd1ccfb4afbe917bec (diff)
downloadobnam2-80ae98bf87c57aa361a13c3dd925455fb67e3f03.tar.gz
feat: improve error messages
All unclear error messages should now be clearer. For example, all the ones related to a file mention the file name and the attempted operation that failed.
Diffstat (limited to 'src/fsentry.rs')
-rw-r--r--src/fsentry.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/fsentry.rs b/src/fsentry.rs
index 35931ab..3f532cc 100644
--- a/src/fsentry.rs
+++ b/src/fsentry.rs
@@ -52,8 +52,8 @@ pub enum FsEntryError {
#[error("Unknown file kind {0}")]
UnknownFileKindCode(u8),
- #[error(transparent)]
- IoError(#[from] std::io::Error),
+ #[error("failed to read symbolic link target {0}: {1}")]
+ ReadLink(PathBuf, std::io::Error),
}
pub type FsEntryResult<T> = Result<T, FsEntryError>;
@@ -64,13 +64,8 @@ impl FilesystemEntry {
let kind = FilesystemKind::from_file_type(meta.file_type());
let symlink_target = if kind == FilesystemKind::Symlink {
debug!("reading symlink target for {:?}", path);
- let target = match read_link(path) {
- Ok(x) => x,
- Err(err) => {
- error!("read_link failed: {}", err);
- return Err(err.into());
- }
- };
+ let target =
+ read_link(path).map_err(|err| FsEntryError::ReadLink(path.to_path_buf(), err))?;
Some(target)
} else {
None