pub enum Error {
EmptyProgramName,
InvalidProgramName {
program_name: String,
},
MissingHome,
UnsupportedShell(Shell),
PathHasNoParent {
path: PathBuf,
},
InvalidTargetPath {
path: PathBuf,
reason: &'static str,
},
NonUtf8Path {
path: PathBuf,
},
InvalidUtf8File {
path: PathBuf,
},
ManagedBlockMissingEnd {
path: PathBuf,
start_marker: String,
end_marker: String,
},
Failure(Box<FailureReport>),
Io {
action: &'static str,
path: PathBuf,
source: Error,
},
}Expand description
Errors returned by shellcomp operations.
Recoverable operational failures that callers are expected to render are wrapped as
Error::Failure with a crate::FailureReport. Lower-level variants represent immediate
input validation or filesystem problems.
Variants§
EmptyProgramName
The requested program name was empty.
InvalidProgramName
The requested program name contains unsupported path separators or reserved values.
MissingHome
HOME could not be resolved for an operation that requires it.
UnsupportedShell(Shell)
The requested shell is known to the API but not implemented yet.
PathHasNoParent
A target path did not contain a parent directory.
InvalidTargetPath
A target path failed explicit validation for security or correctness reasons.
Fields
NonUtf8Path
A path could not be represented as UTF-8 for shell wiring purposes.
InvalidUtf8File
A managed text file contained invalid UTF-8.
ManagedBlockMissingEnd
A managed block start marker was found without its matching end marker.
Fields
Failure(Box<FailureReport>)
A structured recoverable failure report intended for callers.
Match this variant when you need stable failure kinds, affected paths, or caller-facing recovery guidance without parsing a display string.
Io
A filesystem operation failed.
Most user-facing operational I/O failures are mapped to Error::Failure by the public
APIs. This variant is still exposed because low-level helpers and validation paths may
surface it directly.
Implementations§
Source§impl Error
impl Error
Sourcepub fn error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
Returns a stable machine-readable error code.
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Returns whether a retry may succeed with changed environment or timing.
Sourcepub fn trace_id(&self) -> Option<u64>
pub fn trace_id(&self) -> Option<u64>
Returns the operation-scoped trace id when this is a structured failure.
Sourcepub fn as_failure(&self) -> Option<&FailureReport>
pub fn as_failure(&self) -> Option<&FailureReport>
Returns Some when the error is Error::Failure.
Sourcepub fn into_failure(self) -> Option<FailureReport>
pub fn into_failure(self) -> Option<FailureReport>
Converts a Error::Failure into a plain FailureReport.
This is useful when callers need stable, structured failure data and prefer not to branch on internals in each match arm.
Sourcepub fn location(&self) -> Option<&Path>
pub fn location(&self) -> Option<&Path>
Returns the most relevant filesystem location for this error, when one exists.
For Error::Failure, this returns the report’s primary target_path. Use
crate::FailureReport::affected_locations when you need the full set of related paths.
§Examples
use shellcomp::Error;
let error = Error::InvalidProgramName {
program_name: "bad/name".to_owned(),
};
assert_eq!(error.location(), None);Sourcepub fn reason(&self) -> Option<&str>
pub fn reason(&self) -> Option<&str>
Returns a human-readable failure reason intended for caller-side rendering.
This is suitable for logs or CLI output, but callers that need stable branching should
prefer matching Error::Failure and reading crate::FailureReport::kind.
§Examples
use shellcomp::Error;
let error = Error::MissingHome;
assert!(error.reason().is_some());Sourcepub fn next_step(&self) -> Option<&str>
pub fn next_step(&self) -> Option<&str>
Returns a suggested next step for this error, when one exists.
This is primarily intended for CLI or UI layers that want to surface actionable guidance without inventing shell-specific recovery text themselves.
§Examples
use shellcomp::Error;
let error = Error::PathHasNoParent {
path: "/".into(),
};
assert!(error.next_step().is_some());Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()