{"record":{"id":"ce1cddaa5996d912","repo":"can1357/oh-my-pi","slug":"transparent-brush-core-error","errorCode":null,"errorMessage":"transparent (brush_core::Error)","messagePattern":"transparent \\(brush_core::Error\\)","errorType":"exception","errorClass":"DirError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/dirs.rs","lineNumber":13,"sourceCode":"use std::io::Write;\n\nuse brush_core::{ExecutionResult, builtins};\nuse clap::Parser;\n\n#[derive(Debug, thiserror::Error)]\npub(crate) enum DirError {\n\t/// Directory stack is empty.\n\t#[error(\"directory stack is empty\")]\n\tDirStackEmpty,\n\n\t/// A shell error occurred.\n\t#[error(transparent)]\n\tShellError(#[from] brush_core::Error),\n}\n\nimpl From<&DirError> for brush_core::ExecutionExitCode {\n\tfn from(value: &DirError) -> Self {\n\t\tmatch value {\n\t\t\tDirError::DirStackEmpty => Self::GeneralError,\n\t\t\tDirError::ShellError(e) => e.into(),\n\t\t}\n\t}\n}\n\nimpl brush_core::BuiltinError for DirError {}\n\n/// Manage the current directory stack.\n#[derive(Default, Parser)]\npub(crate) struct DirsCommand {\n\t/// Clear the directory stack.","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/dirs.rs#L1-L31","documentation":"This is DirError::ShellError, a #[error(transparent)] wrapper around brush_core::Error. The displayed message is entirely delegated to the inner shell error, so the real cause is whatever brush_core operation failed (invalid directory, chdir failure, etc.). It reaches the caller via the `#[from]` conversion whenever a shell-level error occurs inside the dirs builtin.","triggerScenarios":"pushd to a nonexistent or unreadable directory (chdir fails inside brush_core), or any brush_core::Error raised while executing dirs-family builtins.","commonSituations":"Typo'd target directory, directory removed after path was recorded, permission-restricted directories, or scripts running with a restricted cwd.","solutions":["Look at the transparent inner message — it names the actual shell failure; fix that condition","Verify the target directory exists and is executable (`test -x dir`) before pushd","Check that the directory wasn't deleted/moved by an earlier step in the script","Match on DirError::ShellError and downcast/delegate to brush_core handling if you need structured recovery"],"exampleFix":"// before\npushd \"$OUT_DIR\"  // chdir fails if OUT_DIR unset -> pushd ''\n// after\nmkdir -p \"$OUT_DIR\" && pushd \"$OUT_DIR\"","handlingStrategy":"try-catch","validationCode":"// bash: validate target before pushdif [ -d \"$dir\" ] && [ -x \"$dir\" ]; then pushd \"$dir\"; fi","typeGuard":"fn is_shell_error(e: &DirError) -> Option<&brush_core::Error> { match e { DirError::ShellError(err) => Some(err), _ => None } }","tryCatchPattern":"match run() { Err(DirError::ShellError(inner)) => { eprintln!(\"dirs: {}\", inner); /* handle inner kind */ }, Err(other) => return Err(other), Ok(v) => v }","preventionTips":["Always verify directories exist and are traversable before pushd","Don't assume the transparent message is about the stack — parse it as an arbitrary shell error","Log the full error chain; transparent wrappers hide nothing but require reading the inner text"],"tags":["shell","error-wrapping","rust"],"backgroundTag":"transparent-error-wrapper","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}