{"record":{"id":"22035818d4862fca","repo":"can1357/oh-my-pi","slug":"0-220358","errorCode":null,"errorMessage":"{0}","messagePattern":"\\{0\\}","errorType":"error_code","errorClass":"TouchError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/touch.rs","lineNumber":50,"sourceCode":"use uucore::{display::Quotable, parser::shortcut_value_parser::ShortcutValueParser};\n\nuse brush_core::{ShellExtensions, builtins::Registration};\nuse thiserror::Error as ThisError;\n\nuse crate::host::{Host, Utility, format_usage, matches_parser, util};\n\n#[derive(Debug, ThisError)]\nenum TouchError {\n\t#[error(\"Unable to parse date: {0}\")]\n\tInvalidDateFormat(String),\n\t#[error(\"Source has invalid access or modification time: {0}\")]\n\tInvalidFiletime(FileTime),\n\t#[error(\"failed to get attributes of {}: {}\", .0.quote(), io_error(.1))]\n\tReferenceFileInaccessible(PathBuf, std::io::Error),\n\t#[cfg(windows)]\n\t#[error(\"GetFinalPathNameByHandleW failed with code {0}\")]\n\tWindowsStdoutPathError(String),\n\t#[error(\"{0}\")]\n\tMessage(String),\n}\n\nfn io_error(error: &std::io::Error) -> String {\n\tif error.raw_os_error().is_some() {\n\t\tmatch error.kind() {\n\t\t\tErrorKind::NotFound => \"No such file or directory\".into(),\n\t\t\tErrorKind::PermissionDenied => \"Permission denied\".into(),\n\t\t\tErrorKind::AlreadyExists => \"Already exists\".into(),\n\t\t\tErrorKind::WouldBlock => \"Would block\".into(),\n\t\t\t_ => error.to_string().split(\" (os error \").next().unwrap_or_default().into(),\n\t\t}\n\t} else {\n\t\terror.to_string()\n\t}\n}\n\nfn io_context(error: std::io::Error, context: impl std::fmt::Display) -> TouchError {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/touch.rs#L32-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"Edge cases like unwritable target directories surfaced as free-form text, invalid combinations of flags, or upstream messages propagated without a dedicated variant.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match result {\n    Err(TouchError::Message(msg)) => {\n        // free-form diagnostic: log it and decide from its text\n        eprintln!(\"touch failed: {msg}\");\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["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"],"tags":["touch","generic-error","diagnostics"],"backgroundTag":"generic-operation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}