Skip to main content

ext4_mkfs/
error.rs

1//! Error types for ext4-mkfs operations.
2
3use thiserror::Error;
4
5/// Result type for ext4-mkfs operations.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Errors that can occur during ext4-mkfs operations.
9#[derive(Debug, Error)]
10pub enum Error {
11    /// I/O error from block device operations
12    #[error("I/O error: {0}")]
13    Io(#[from] std::io::Error),
14
15    /// lwext4 returned an error code
16    #[error("lwext4 error: {0}")]
17    Lwext4(i32),
18
19    /// Invalid configuration
20    #[error("Invalid configuration: {0}")]
21    InvalidConfig(String),
22
23    /// Block device is too small
24    #[error("Block device too small: minimum {min} bytes, got {actual} bytes")]
25    DeviceTooSmall { min: u64, actual: u64 },
26}
27
28impl Error {
29    /// Create an error from an lwext4 error code.
30    pub fn from_lwext4(code: i32) -> Self {
31        Error::Lwext4(code)
32    }
33}