use thiserror::Error;
#[derive(Debug, Error)]
pub enum DiceError {
#[error("Tray not found: {0}")]
TrayNotFound(String),
#[error("Tray already exists: {0}")]
TrayAlreadyExists(String),
#[error("Die not found: {0}")]
DieNotFound(String),
#[error("Die already exists: {0}")]
DieAlreadyExists(String),
#[error("Slot #{slot_id} not found in tray '{tray}'")]
SlotNotFound {
tray: String,
slot_id: u32,
},
#[error("Cannot modify builtin die: {0}")]
CannotModifyBuiltin(String),
#[error("Cannot delete die '{die}' — in use by trays: {trays:?}")]
CannotDeleteInUse {
die: String,
trays: Vec<String>,
},
#[error("Storage error: {0}")]
StorageError(String),
#[error("Invalid expression: {0}")]
InvalidExpression(String),
#[error("Invalid arguments: {0}")]
InvalidArguments(String),
#[error(
"Tray '{tray}' does not contain enough matching dice for '{die}' (requested {requested}, available {available})"
)]
InsufficientMatchingDice {
tray: String,
die: String,
requested: usize,
available: usize,
},
#[error("Die must have at least 1 face")]
InvalidFaceCount,
#[error("Numeric dice must have at least 2 faces: {0}")]
InvalidNumericDie(String),
#[error("Invalid name: must not be empty or contain whitespace")]
InvalidName,
}
pub type Result<T> = std::result::Result<T, DiceError>;