Skip to content

Commit 2617af7

Browse files
committed
refactor(rm): improve error context in check_one_fs
Replace empty error strings with descriptive messages when path parent or mount point resolution fails. This aids in debugging by identifying specifically which path caused the resolution failure during the one-file-system check.
1 parent a0df78a commit 2617af7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/uu/rm/src/rm.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,16 @@ fn check_one_fs(path: &Path, options: &Options) -> Result<(), String> {
750750
.map_err(|err| format!("cannot canonicalize {}: {err}", path.quote()))?;
751751

752752
// Get parent path, handling root case
753-
let parent_canon = child_canon.parent().ok_or("")?.to_path_buf();
753+
let parent_canon = child_canon
754+
.parent()
755+
.ok_or_else(|| format!("cannot get parent of {}", child_canon.quote()))?
756+
.to_path_buf();
754757

755758
// Find mount points for child and parent
756-
let child_mount = mount_for_path(&child_canon, &fs_list).ok_or("")?;
757-
let parent_mount = mount_for_path(&parent_canon, &fs_list).ok_or("")?;
759+
let child_mount = mount_for_path(&child_canon, &fs_list)
760+
.ok_or_else(|| format!("cannot find mount point for {}", child_canon.quote()))?;
761+
let parent_mount = mount_for_path(&parent_canon, &fs_list)
762+
.ok_or_else(|| format!("cannot find mount point for {}", parent_canon.quote()))?;
758763

759764
// Check if child and parent are on the same device
760765
if child_mount.dev_id != parent_mount.dev_id {

0 commit comments

Comments
 (0)