diff --git a/crates/idfoto-core/src/error.rs b/crates/idfoto-core/src/error.rs index 63391e4..c509fa3 100644 --- a/crates/idfoto-core/src/error.rs +++ b/crates/idfoto-core/src/error.rs @@ -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 = std::result::Result; diff --git a/crates/idfoto-core/src/lib.rs b/crates/idfoto-core/src/lib.rs index a91e735..92a114f 100644 --- a/crates/idfoto-core/src/lib.rs +++ b/crates/idfoto-core/src/lib.rs @@ -1 +1,2 @@ pub mod error; +pub use error::{IdfotoError, Result};