use thiserror::Error;
pub type FingerprintResult<T> = Result<T, FingerprintError>;
#[derive(Debug, Error)]
pub enum FingerprintError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("ZIP archive error: {0}")]
Zip(#[from] zip::result::ZipError),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("YAML error: {0}")]
Yaml(#[from] serde_yaml::Error),
#[error("CSV error: {0}")]
Csv(#[from] csv::Error),
#[error("Parquet error: {0}")]
Parquet(#[from] parquet::errors::ParquetError),
#[error("Arrow error: {0}")]
Arrow(#[from] arrow::error::ArrowError),
#[error("Invalid fingerprint format: {0}")]
InvalidFormat(String),
#[error("Missing required component: {0}")]
MissingComponent(String),
#[error("Checksum mismatch for {file}: expected {expected}, got {actual}")]
ChecksumMismatch {
file: String,
expected: String,
actual: String,
},
#[error("Unsupported fingerprint version: {0}")]
UnsupportedVersion(String),
#[error("Privacy budget exhausted: epsilon={spent}, limit={limit}")]
PrivacyBudgetExhausted { spent: f64, limit: f64 },
#[error("Insufficient data: need at least {required} rows, got {actual}")]
InsufficientData { required: usize, actual: usize },
#[error("Statistical error: {0}")]
StatisticalError(String),
#[error("Validation error: {0}")]
ValidationError(String),
#[error("Config synthesis error: {0}")]
SynthesisError(String),
#[error("Extraction error in {extractor}: {message}")]
ExtractionError { extractor: String, message: String },
#[error("Privacy constraint violated: {0}")]
PrivacyViolation(String),
#[error("Matrix operation error: {0}")]
MatrixError(String),
#[error("Distribution fitting error: {0}")]
DistributionFitError(String),
#[error("pii denylist: {0}")]
PiiDenylist(String),
}
impl FingerprintError {
pub fn extraction(extractor: &str, message: impl Into<String>) -> Self {
Self::ExtractionError {
extractor: extractor.to_string(),
message: message.into(),
}
}
}