pub fn enrich_fs_error(path: &Path, op: &'static str, err: Error) -> ErrorExpand description
Wrap an io::Error produced by a filesystem operation against path
with a heddle-context message naming both the operation and the path.
The mapping covers the cases users actually hit and the messages we promise from heddle’s CLI surface:
- ENOTEMPTY — usually
remove_diragainst a directory that still holds untracked or explicitly ignored content, such as build output. The high-level fix is to leave the directory in place, but when the error does surface (e.g. a path the planner did expect to remove), the message names the path so the user can investigate. - EACCES — naming the path and the action (“removing”, “writing”, “renaming”) is enough for the user to inspect mode bits.
- ENOENT — caller-driven: only enriched when the operation
expected the path to exist (so optional reads like a missing index
pass through unchanged via the
is_not_foundpredicate). - EROFS — points the user at the filesystem mount, not at heddle.
- EXDEV — points the user at the temp path / mount mismatch.
- ENOSPC — same actionable disk-full message the snapshot path already relies on.
op is a verb in the present-progressive (“writing”, “removing”,
“renaming”, “creating”) so the resulting message reads naturally:
"could not remove because it contains content...".
The wrapped error preserves raw_os_error() (callers still classify
disk-full via is_out_of_space) and exposes the original io::Error
through the Error::source chain (so RUST_BACKTRACE=1 and
anyhow’s chain printer still surface the OS error).