domino_lib/utils/
error.rs1#[derive(Debug, PartialEq)]
2pub enum DominoError {
3 InvalidLength,
4 UnsolvablePuzzle,
5 NotValidPuzzle,
6 Timeout,
7 ModelGenerationError(String),
8 ModelError(String),
9 GenerationError(String),
10 InvalidClass(String),
11 EmptyPuzzle,
12}
13
14impl std::fmt::Display for DominoError {
15 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16 match self {
17 Self::InvalidLength => write!(f, "The puzzle length is not correct"),
18 Self::UnsolvablePuzzle => write!(f, "The puzzle has no solutions"),
19 Self::NotValidPuzzle => write!(
20 f,
21 "The puzzle is not valid/unique, it has multiple solutions"
22 ),
23 Self::Timeout => write!(f, "The puzzle took too long to solve"),
24 Self::ModelGenerationError(message) => write!(f, "{}", message),
25 Self::ModelError(message) => write!(f, "{}", message),
26 Self::GenerationError(message) => write!(
27 f,
28 "The puzzle could not be generated with the requires parameters: {}",
29 message
30 ),
31 Self::InvalidClass(message) => write!(f, "{}", message),
32 Self::EmptyPuzzle => write!(f, "The puzzle is empty"),
33 }
34 }
35}
36
37impl std::error::Error for DominoError {}