Introduce 'Error' enum

This commit is contained in:
Bruno BELANYI 2022-07-27 23:24:24 +02:00
parent f483492b17
commit 566dbf2119
2 changed files with 17 additions and 0 deletions

16
src/error.rs Normal file
View file

@ -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 {}

View file

@ -1,3 +1,4 @@
pub mod board; pub mod board;
pub mod error;
pub mod movegen; pub mod movegen;
pub mod utils; pub mod utils;