diff --git a/src/build.rs b/src/build.rs index 10d7a94..c0bcdc6 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,6 +1,7 @@ use std::io::{Result, Write}; pub mod board; +pub mod error; pub mod movegen; pub mod utils; diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..535bd7b --- /dev/null +++ b/src/error.rs @@ -0,0 +1,16 @@ +/// A singular type for all errors that could happen when using this library. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum Error { + InvalidFen, +} + +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let error_msg = match self { + Self::InvalidFen => "Invalid FEN input", + }; + write!(f, "{}", error_msg) + } +} + +impl std::error::Error for Error {} diff --git a/src/lib.rs b/src/lib.rs index bfcf0bd..c1b793f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ pub mod board; +pub mod error; pub mod movegen; pub mod utils;