sys_shred/error/mod.rs
1//! # Security-First Error Handling
2//!
3//! This module defines the robust error infrastructure for `sys-shred`.
4//! It utilizes `thiserror` to provide descriptive, context-aware error messages
5//! while maintaining strict type safety across the application.
6
7use thiserror::Error;
8
9/// The primary error taxonomy for the `sys-shred` ecosystem.
10///
11/// Every potential failure point, from low-level filesystem I/O to high-level
12/// cryptographic entropy exhaustion, is represented here.
13#[derive(Debug, Error)]
14pub enum ShredError {
15 /// Errors originating from the underlying Operating System's file operations.
16 /// This includes permission issues, missing files, or hardware failures.
17 #[error("System I/O Failure: {0}")]
18 Io(#[from] std::io::Error),
19
20 /// Errors encountered during the parsing or validation of Command Line Arguments.
21 #[error("CLI Configuration Error: {0}")]
22 Cli(String),
23
24 /// Errors related to the failure of cryptographic random number generation.
25 /// Critical for ensuring the integrity of the overwriting process.
26 #[error("Cryptographic Entropy Error: {0}")]
27 Entropy(String),
28
29 /// Errors triggered when a target path is logically invalid (e.g., pointing to a directory
30 /// when a file is expected) or otherwise inaccessible.
31 #[error("Inaccessible Path Error: {0}")]
32 InvalidPath(String),
33
34 /// Errors occurring during the filename randomization or metadata scrubbing phase.
35 #[error("Metadata Obfuscation Failure: {0}")]
36 Obfuscation(String),
37}
38
39/// A specialized `Result` type alias for all `sys-shred` operations.
40///
41/// This type is used consistently across the library to enforce explicit
42/// error propagation and handling.
43pub type ShredResult<T> = Result<T, ShredError>;