entrenar/optim/dp/error.rs
1//! Error types for the Differential Privacy module.
2
3use thiserror::Error;
4
5/// DP errors
6#[derive(Debug, Error)]
7pub enum DpError {
8 #[error("Privacy budget exhausted: spent {spent:.4} > allowed {budget:.4}")]
9 BudgetExhausted { spent: f64, budget: f64 },
10
11 #[error("Invalid configuration: {0}")]
12 InvalidConfig(String),
13
14 #[error("Gradient computation failed: {0}")]
15 GradientError(String),
16
17 #[error("DP error: {0}")]
18 Internal(String),
19}
20
21/// Result type for DP operations
22pub type Result<T> = std::result::Result<T, DpError>;