rg-chess 0.2.4

Chess Game with graphical interface.
Documentation
use thiserror::Error;

use crate::{Board, ChessMove};

/// Error that can happen during the game.
///
/// derive from PartialEq for UnitTest
#[derive(Error, Clone, PartialEq, Eq, Debug)]
pub enum Error {
    /// The move on a particular board doesn't respect the chess rules.
    #[error(
        "Invalid move ({}) on the given board ({}) according to the chess rule",
        invalid_move,
        board
    )]
    InvalidMove {
        board: Board,
        invalid_move: ChessMove,
    },

    /// The FEN (Forsyth-Edwards Notation) string is invalid.
    #[error("Invalid FEN string: {}", fen)]
    InvalidFen { fen: String },

    /// An attempt was made to create a move from an invalid SAN string.
    #[error("The string specified does not contain a valid SAN notation move")]
    InvalidSanMove,

    /// An attempt was made to create a square from an invalid string.
    #[error("The string specified does not contain a valid algebraic notation square")]
    InvalidSquare,

    /// An attempt was made to convert a string not equal to "1"-"8" to a rank.
    #[error("The string specified does not contain a valid rank")]
    InvalidRank,

    /// An attempt was made to convert a string not equal to "a"-"h" to a file.
    #[error("The string specified does not contain a valid file")]
    InvalidFile,
}