can1357/oh-my-pi · error · TouchError
{0}
Error message
{0} What it means
TouchError::Message(String) is the catch-all variant of the touch error enum; any ad-hoc error message is wrapped verbatim via `{0}`. Seeing it means the touch builtin hit a condition not covered by the specific variants and surfaced a plain diagnostic string.
Source
Thrown at crates/pi-builtins/src/touch.rs:50
use uucore::{display::Quotable, parser::shortcut_value_parser::ShortcutValueParser};
use brush_core::{ShellExtensions, builtins::Registration};
use thiserror::Error as ThisError;
use crate::host::{Host, Utility, format_usage, matches_parser, util};
#[derive(Debug, ThisError)]
enum TouchError {
#[error("Unable to parse date: {0}")]
InvalidDateFormat(String),
#[error("Source has invalid access or modification time: {0}")]
InvalidFiletime(FileTime),
#[error("failed to get attributes of {}: {}", .0.quote(), io_error(.1))]
ReferenceFileInaccessible(PathBuf, std::io::Error),
#[cfg(windows)]
#[error("GetFinalPathNameByHandleW failed with code {0}")]
WindowsStdoutPathError(String),
#[error("{0}")]
Message(String),
}
fn io_error(error: &std::io::Error) -> String {
if error.raw_os_error().is_some() {
match error.kind() {
ErrorKind::NotFound => "No such file or directory".into(),
ErrorKind::PermissionDenied => "Permission denied".into(),
ErrorKind::AlreadyExists => "Already exists".into(),
ErrorKind::WouldBlock => "Would block".into(),
_ => error.to_string().split(" (os error ").next().unwrap_or_default().into(),
}
} else {
error.to_string()
}
}
fn io_context(error: std::io::Error, context: impl std::fmt::Display) -> TouchError {View on GitHub (pinned to 9690622007)
Solutions
- Read the wrapped message text — it is the actual diagnostic
- Fix the specific condition named in the message (path, permissions, flags)
- If the message is unclear, reproduce with a minimal `touch` invocation to isolate the failing flag
Defensive patterns
Strategy: try-catch
Try / catch
match result {
Err(TouchError::Message(msg)) => {
// free-form diagnostic: log it and decide from its text
eprintln!("touch failed: {msg}");
}
other => other.map(|_| ()),
} Prevention
- Use the specific flag combinations documented for touch instead of exotic mixes
- Test touch invocations in scripts with --dry-run equivalents or on temp files first
- Capture stderr of the builtin to surface the wrapped message in your tooling
When it happens
Trigger: Any generic failure inside the touch builtin that isn't a date-parse, filetime, reference-stat, or Windows-handle error; the concrete text is in the error's Display output.
Common situations: Edge cases like unwritable target directories surfaced as free-form text, invalid combinations of flags, or upstream messages propagated without a dedicated variant.
Related errors
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/22035818d4862fca.
Report an issue: GitHub.