1use std::fmt;
2
3#[derive(Debug)]
4pub enum FenError {
5 NotEnoughFields(String),
6 BadPieceNotation(String),
7 BadActiveColor(String),
8 BadEnPassant(String),
9 BadHalfmove(String),
10 BadFullmove(String),
11}
12
13impl fmt::Display for FenError {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 match self {
16 FenError::NotEnoughFields(msg) => write!(f, "Not enough FEN fields: {}", msg),
17 FenError::BadPieceNotation(msg) => write!(f, "Piece notation error: {}", msg),
18 FenError::BadActiveColor(msg) => write!(f, "Active color error: {}", msg),
19 FenError::BadEnPassant(msg) => write!(f, "En passant error: {}", msg),
20 FenError::BadHalfmove(msg) => write!(f, "Halfmove error: {}", msg),
21 FenError::BadFullmove(msg) => write!(f, "Fullmove error: {}", msg),
22 }
23 }
24}
25
26impl std::error::Error for FenError {}