seer/src/error.rs

20 lines
555 B
Rust
Raw Normal View History

2022-07-27 23:24:24 +02:00
/// A singular type for all errors that could happen when using this library.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[non_exhaustive]
2022-07-27 23:24:24 +02:00
pub enum Error {
InvalidFen,
2022-07-28 21:17:12 +02:00
InvalidPosition,
2022-07-27 23:24:24 +02:00
}
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",
2022-07-28 21:17:12 +02:00
Self::InvalidPosition => "Invalid position",
2022-07-27 23:24:24 +02:00
};
write!(f, "{}", error_msg)
}
}
impl std::error::Error for Error {}