Introduce 'Error' enum
This commit is contained in:
parent
8102b08cf0
commit
7e23cb8f77
|
@ -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
16
src/error.rs
Normal 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 {}
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue