server/domain/cards/error.rs
1use thiserror::*;
2
3/// Errors that occur when manipulating cards in piles, hands, crib, etc.
4#[derive(Debug, PartialEq, Eq, Error)]
5pub enum CardsError {
6 /// The string could not be parsed into a valid `Card`.
7 /// Example: `"X5"`, `"14H"`, `"Ah"` (invalid suit), empty string.
8 #[error("invalid card")]
9 InvalidCard(String),
10
11 /// A requested card is not present in the pile/hand/deck.
12 #[error("card {0} not found")]
13 CardNotFound(String),
14
15 /// Not enough cards are available to fulfill a cut or deal request.
16 #[error("cannot take cards required {0} of cards")]
17 CardsNotAvailable(u8),
18}