1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum FederationError {
8 #[error("privacy budget exhausted: spent {spent:.4}, limit {limit:.4}")]
9 PrivacyBudgetExhausted { spent: f64, limit: f64 },
10
11 #[error("invalid epsilon value: {0} (must be > 0)")]
12 InvalidEpsilon(f64),
13
14 #[error("invalid delta value: {0} (must be in (0, 1))")]
15 InvalidDelta(f64),
16
17 #[error("segment validation failed: {0}")]
18 SegmentValidation(String),
19
20 #[error("version mismatch: expected {expected}, got {got}")]
21 VersionMismatch { expected: u32, got: u32 },
22
23 #[error("signature verification failed")]
24 SignatureVerification,
25
26 #[error("witness chain broken at index {0}")]
27 WitnessChainBroken(usize),
28
29 #[error("insufficient observations: need {needed}, have {have}")]
30 InsufficientObservations { needed: u64, have: u64 },
31
32 #[error("quality below threshold: {score:.4} < {threshold:.4}")]
33 QualityBelowThreshold { score: f64, threshold: f64 },
34
35 #[error("export rate limited: next export allowed at {next_allowed_epoch_s}")]
36 RateLimited { next_allowed_epoch_s: u64 },
37
38 #[error("PII detected after stripping: {field}")]
39 PiiLeakDetected { field: String },
40
41 #[error("Byzantine outlier detected from contributor {contributor}")]
42 ByzantineOutlier { contributor: String },
43
44 #[error("aggregation requires at least {min} contributions, got {got}")]
45 InsufficientContributions { min: usize, got: usize },
46
47 #[error("serialization error: {0}")]
48 Serialization(String),
49
50 #[error("io error: {0}")]
51 Io(String),
52}