domino_lib/types/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#[derive(Debug)]
pub enum DominoError {
    InvalidLength,
    UnsolvablePuzzle,
    NotValidPuzzle,
    Timeout,
    ModelGenerationError(String),
    ModelError(String),
}

impl std::fmt::Display for DominoError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::InvalidLength => write!(f, "The puzzle length is not correct"),
            Self::UnsolvablePuzzle => write!(f, "The puzzle has no solutions"),
            Self::NotValidPuzzle => write!(f, "The puzzle is not valid/unique, it has multiple solutions"),
            Self::Timeout => write!(f, "The puzzle took too long to solve"),
            Self::ModelGenerationError(message) => write!(f, "{}", message),
            Self::ModelError(message) => write!(f, "{}", message),
        }
    }
}

impl std::error::Error for DominoError {}