From 2e08e3c73073df9db367fa93c24e65d4c72a7846 Mon Sep 17 00:00:00 2001 From: lashman Date: Tue, 25 Mar 2025 18:24:24 +0200 Subject: [PATCH] core error types --- cruciverb-core/src/error.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cruciverb-core/src/error.rs diff --git a/cruciverb-core/src/error.rs b/cruciverb-core/src/error.rs new file mode 100644 index 0000000..9967757 --- /dev/null +++ b/cruciverb-core/src/error.rs @@ -0,0 +1,30 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum CrucivError { + #[error("{0}")] + Generation(String), + + #[error("Generation timed out - try a smaller grid or lower fill percentage")] + Timeout(u64), + + #[error("invalid grid: {0}")] + InvalidGrid(String), + + #[error("validation failed: {0}")] + Validation(String), + + #[error("dictionary error: {0}")] + Dictionary(String), + + #[error("no clue found for word: {0}")] + MissingClue(String), + + #[error(transparent)] + Io(#[from] std::io::Error), + + #[error(transparent)] + Json(#[from] serde_json::Error), +} + +pub type Result = std::result::Result;