rustoku_lib/error.rs
1//! Error module for Rustoku.
2
3use thiserror::Error;
4
5/// Represents the types of errors that can occur while working with Sudoku puzzles.
6#[derive(Debug, Error)]
7pub enum RustokuError {
8 /// The number of clues provided for puzzle generation is not between 17 and 81.
9 #[error("Clues must be between 17 and 81 for a valid Sudoku puzzle")]
10 InvalidClueCount,
11 /// The input string does not contain exactly 81 characters.
12 #[error("Input string must be exactly 81 characters long")]
13 InvalidInputLength,
14 /// The input string contains characters other than digits `0-9` or `.` or `_`.
15 #[error("Input string must contain only digits '0'-'9'")]
16 InvalidInputCharacter,
17 /// The initial board contains duplicate values in rows, columns, or 3x3 boxes.
18 #[error("Initial board contains duplicates")]
19 DuplicateValues,
20 /// The puzzle generation process failed.
21 #[error("Puzzle generation failed ")]
22 GenerateFailure,
23}