pub enum AppError {
Io {
context: String,
source: Error,
},
InvalidDirectory(String),
InvalidGlob(String),
InvalidDate(String),
InvalidTimezone(String),
InvalidOutput(String),
DateRange(String),
Serialization(String),
Regex(String),
}Expand description
Application error. Wraps IO and validation failures encountered by the CLI.
Variants§
Io
Underlying IO error (file read, write, etc.) with the path or
context label that triggered it. Use the AppError::io constructor;
the blanket From<io::Error> is intentionally absent because losing
the path on every ? is exactly what this variant was reshaped to
prevent.
Fields
InvalidDirectory(String)
--dir does not exist or is not a directory
InvalidGlob(String)
--glob pattern is malformed or uses an unsupported feature
InvalidDate(String)
CLI date argument is not parseable as YYYY-MM-DD
InvalidTimezone(String)
--tz is not a valid IANA timezone
InvalidOutput(String)
--output path is unsafe (missing parent, symlink, etc.)
DateRange(String)
A date window that cannot be built as asked: --from after --to, a
window argument in a scope that has no window (--agenda tasks), or a
first day of the week the scope cannot draw (--agenda month-grid
with --week-start today). Named after its first use; the variant is
public API, so the wider meaning is documented here rather than split
into a new one.
Serialization(String)
JSON or other serializer reported an error
Regex(String)
Regex compilation failed
Implementations§
Source§impl AppError
impl AppError
Sourcepub fn exit_code(&self) -> i32
pub fn exit_code(&self) -> i32
Process exit code that classifies this error category.
2– usage / input-validation failures the user can correct by changing CLI arguments (matches clap’s own argument-error exit).74– IO failures (EX_IOERRfromsysexits.h): unreadable files, write failures.70– internal software errors (EX_SOFTWARE): a regex we built ourselves did not compile, or our own serializer failed.
Sourcepub fn io(context: impl Into<String>, source: Error) -> Self
pub fn io(context: impl Into<String>, source: Error) -> Self
Construct an AppError::Io while preserving the underlying source.
The context is a free-form label printed by Display: prefer the
real filesystem path when one is available (p.display()), fall back
to the sentinel <stdout> / <stderr> for the standard streams.
Use this in place of ? on io::Error — the blanket From was
removed precisely so that no IO failure can sneak through without a
caller-supplied location.
Trait Implementations§
Source§impl Error for AppError
impl Error for AppError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()