datasynth_fingerprint/
error.rs1use thiserror::Error;
4
5pub type FingerprintResult<T> = Result<T, FingerprintError>;
7
8#[derive(Debug, Error)]
10pub enum FingerprintError {
11 #[error("I/O error: {0}")]
13 Io(#[from] std::io::Error),
14
15 #[error("ZIP archive error: {0}")]
17 Zip(#[from] zip::result::ZipError),
18
19 #[error("JSON error: {0}")]
21 Json(#[from] serde_json::Error),
22
23 #[error("YAML error: {0}")]
25 Yaml(#[from] serde_yaml::Error),
26
27 #[error("CSV error: {0}")]
29 Csv(#[from] csv::Error),
30
31 #[error("Parquet error: {0}")]
33 Parquet(#[from] parquet::errors::ParquetError),
34
35 #[error("Arrow error: {0}")]
37 Arrow(#[from] arrow::error::ArrowError),
38
39 #[error("Invalid fingerprint format: {0}")]
41 InvalidFormat(String),
42
43 #[error("Missing required component: {0}")]
45 MissingComponent(String),
46
47 #[error("Checksum mismatch for {file}: expected {expected}, got {actual}")]
49 ChecksumMismatch {
50 file: String,
51 expected: String,
52 actual: String,
53 },
54
55 #[error("Unsupported fingerprint version: {0}")]
57 UnsupportedVersion(String),
58
59 #[error("Privacy budget exhausted: epsilon={spent}, limit={limit}")]
61 PrivacyBudgetExhausted { spent: f64, limit: f64 },
62
63 #[error("Insufficient data: need at least {required} rows, got {actual}")]
65 InsufficientData { required: usize, actual: usize },
66
67 #[error("Statistical error: {0}")]
69 StatisticalError(String),
70
71 #[error("Validation error: {0}")]
73 ValidationError(String),
74
75 #[error("Config synthesis error: {0}")]
77 SynthesisError(String),
78
79 #[error("Extraction error in {extractor}: {message}")]
81 ExtractionError { extractor: String, message: String },
82
83 #[error("Privacy constraint violated: {0}")]
85 PrivacyViolation(String),
86
87 #[error("Matrix operation error: {0}")]
89 MatrixError(String),
90
91 #[error("Distribution fitting error: {0}")]
93 DistributionFitError(String),
94
95 #[error("pii denylist: {0}")]
97 PiiDenylist(String),
98}
99
100impl FingerprintError {
101 pub fn extraction(extractor: &str, message: impl Into<String>) -> Self {
103 Self::ExtractionError {
104 extractor: extractor.to_string(),
105 message: message.into(),
106 }
107 }
108}