Introduce 'Error' enum

This commit is contained in:
Bruno BELANYI 2022-07-27 23:24:24 +02:00
parent 8102b08cf0
commit 7e23cb8f77
3 changed files with 18 additions and 0 deletions

View file

@ -1,6 +1,7 @@
use std::io::{Result, Write}; use std::io::{Result, Write};
pub mod board; pub mod board;
pub mod error;
pub mod movegen; pub mod movegen;
pub mod utils; pub mod utils;

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;