1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum MerminError {
8 #[error("dimension mismatch: expected {expected}, got {got}")]
9 DimensionMismatch { expected: String, got: String },
10
11 #[error("contour has {n} points, need at least {min}")]
12 ContourTooShort { n: usize, min: usize },
13
14 #[error("empty cell mask: label {label} has zero pixels")]
15 EmptyMask { label: i32 },
16
17 #[error("singular matrix in eigendecomposition")]
18 SingularMatrix,
19
20 #[error("invalid k-atic order: k={k}, must be positive")]
21 InvalidK { k: u32 },
22
23 #[error("no cells found in segmentation")]
24 NoCells,
25
26 #[error("Poincare-Hopf violation: charge sum {sum:.3} != Euler characteristic {chi}")]
27 PoincareHopfViolation { sum: f64, chi: i32 },
28
29 #[error("{0}")]
30 Other(String),
31}
32
33pub type Result<T> = std::result::Result<T, MerminError>;