1#[derive(Clone, Debug, PartialEq, Eq)]
9pub enum MiloError {
10 SizeMismatch {
12 img1_width: u32,
13 img1_height: u32,
14 img2_width: u32,
15 img2_height: u32,
16 },
17 InputTooSmall {
19 width: u32,
20 height: u32,
21 minimum: u32,
22 },
23 Options(String),
25}
26
27impl std::fmt::Display for MiloError {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match self {
30 MiloError::SizeMismatch {
31 img1_width,
32 img1_height,
33 img2_width,
34 img2_height,
35 } => write!(
36 f,
37 "Image sizes do not match: {}x{} vs {}x{}",
38 img1_width, img1_height, img2_width, img2_height
39 ),
40 MiloError::InputTooSmall {
41 width,
42 height,
43 minimum,
44 } => write!(
45 f,
46 "Image {}x{} is too small for this metric: needs at least {}x{}",
47 width, height, minimum, minimum
48 ),
49 MiloError::Options(e) => write!(f, "Invalid metric options: {}", e),
50 }
51 }
52}
53
54impl std::error::Error for MiloError {}