lmn_core/threshold/
error.rs1#[derive(Debug)]
3pub enum ThresholdError {
4 ParseError(String),
6 ValidationError(String),
8}
9
10impl std::fmt::Display for ThresholdError {
11 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12 match self {
13 Self::ParseError(msg) => write!(f, "Threshold parse error: {}", msg),
14 Self::ValidationError(msg) => write!(f, "Threshold validation error: {}", msg),
15 }
16 }
17}
18
19impl std::error::Error for ThresholdError {}
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn display_parse_error() {
27 let e = ThresholdError::ParseError("bad json".to_string());
28 assert!(e.to_string().contains("bad json"));
29 }
30
31 #[test]
32 fn display_validation_error() {
33 let e = ThresholdError::ValidationError("out of range".to_string());
34 assert!(e.to_string().contains("out of range"));
35 }
36}