feat: add IdfotoError enum with thiserror

This commit is contained in:
adlee-was-taken
2026-04-11 22:53:19 -04:00
parent 34cc926f82
commit a77a1c8b42
2 changed files with 42 additions and 1 deletions

View File

@@ -1 +1,41 @@
// Error types will be filled in Task 2 use thiserror::Error;
#[derive(Debug, Error)]
pub enum IdfotoError {
#[error("key derivation failed: {0}")]
Kdf(String),
#[error("encryption failed: {0}")]
Encrypt(String),
#[error("decryption failed: wrong key or corrupted data")]
Decrypt,
#[error("invalid vault format: {0}")]
Format(String),
#[error("entry not found: {0}")]
EntryNotFound(String),
#[error("imgsecret: {0}")]
ImgSecret(String),
#[error("image too small: need at least {min_width}x{min_height}, got {actual_width}x{actual_height}")]
ImageTooSmall {
min_width: u32,
min_height: u32,
actual_width: u32,
actual_height: u32,
},
#[error("extraction failed: no valid secret found in image")]
ExtractionFailed,
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("device key error: {0}")]
DeviceKey(String),
}
pub type Result<T> = std::result::Result<T, IdfotoError>;

View File

@@ -1 +1,2 @@
pub mod error; pub mod error;
pub use error::{IdfotoError, Result};