feat: first-draft preview-capable zosstorage
- CLI: add topology selection (-t/--topology), preview flags (--show/--report), and removable policy override (--allow-removable) (src/cli/args.rs) - Config: built-in sensible defaults; deterministic overlays for logging, fstab, removable, topology (src/config/loader.rs) - Device: discovery via /proc + /sys with include/exclude regex and removable policy (src/device/discovery.rs) - Idempotency: detection via blkid; safe emptiness checks (src/idempotency/mod.rs) - Partition: topology-driven planning (Single, DualIndependent, BtrfsRaid1, SsdHddBcachefs) (src/partition/plan.rs) - FS: planning + creation (mkfs.vfat, mkfs.btrfs, bcachefs format) and UUID capture via blkid (src/fs/plan.rs) - Orchestrator: pre-flight with preview JSON (disks, partition_plan, filesystems_planned, mount scheme). Skips emptiness in preview; supports stdout+file (src/orchestrator/run.rs) - Util/Logging/Types/Errors: process execution, tracing, shared types (src/util/mod.rs, src/logging/mod.rs, src/types.rs, src/errors.rs) - Docs: add README with exhaustive usage and preview JSON shape (README.md) Builds and unit tests pass: discovery, util, idempotency helpers, and fs parser tests.
This commit is contained in:
56
src/errors.rs
Normal file
56
src/errors.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
//! Common error types and result alias for zosstorage.
|
||||
|
||||
use thiserror::Error as ThisError;
|
||||
|
||||
/// Top-level error for zosstorage covering configuration, validation,
|
||||
/// device discovery, partitioning, filesystem, mounting, reporting,
|
||||
/// and external tool invocation failures.
|
||||
#[derive(Debug, ThisError)]
|
||||
pub enum Error {
|
||||
/// Invalid or malformed configuration input.
|
||||
#[error("configuration error: {0}")]
|
||||
Config(String),
|
||||
|
||||
/// Semantic validation failure.
|
||||
#[error("validation error: {0}")]
|
||||
Validation(String),
|
||||
|
||||
/// Errors related to device discovery and probing.
|
||||
#[error("device discovery error: {0}")]
|
||||
Device(String),
|
||||
|
||||
/// Partitioning or GPT manipulation failures.
|
||||
#[error("partitioning error: {0}")]
|
||||
Partition(String),
|
||||
|
||||
/// Filesystem creation or probing failures.
|
||||
#[error("filesystem error: {0}")]
|
||||
Filesystem(String),
|
||||
|
||||
/// Mount operation failures.
|
||||
#[error("mount error: {0}")]
|
||||
Mount(String),
|
||||
|
||||
/// State report construction or write failures.
|
||||
#[error("report error: {0}")]
|
||||
Report(String),
|
||||
|
||||
/// External system tool invocation failure with captured stderr.
|
||||
#[error("external tool '{tool}' failed with status {status}: {stderr}")]
|
||||
Tool {
|
||||
tool: String,
|
||||
status: i32,
|
||||
stderr: String,
|
||||
},
|
||||
|
||||
/// Placeholder for not-yet-implemented functionality (e.g., --force).
|
||||
#[error("unimplemented: {0}")]
|
||||
Unimplemented(&'static str),
|
||||
|
||||
/// Any other error wrapped with context.
|
||||
#[error(transparent)]
|
||||
Other(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
/// Crate-wide result alias.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
Reference in New Issue
Block a user