core_rust/core/game/utils/
errors.rs

1use super::actions::Action;
2use crate::core::game::state::State;
3use thiserror::Error;
4
5/// Errors raised by invalid gridworld configurations or illegal simulation steps.
6#[derive(Debug, Error)]
7pub enum GameError {
8    #[error("Invalid world configuration: world must be non-empty and square")]
9    WorldShapeError,
10
11    #[error("Invalid world configuration: tile character {character:?} not recognized")]
12    InvalidTileCharacter { character: char },
13
14    #[error("Invalid world configuration: two goals provided")]
15    DuplicateGoal,
16
17    #[error("Invalid world configuration: no goal provided")]
18    MissingGoal,
19
20    #[error("Simulation Error: Attempted illegal game‐logic operation")]
21    GameLogicError,
22
23    #[error("Simulation Error: Unit not found on the field")]
24    UnitNotFound,
25
26    #[error{"Simulation Error: Invalud action {action:?}"}]
27    InvalidAction { action: Action },
28
29    #[error("Simulation Error: invalid action {action:?} in state {state:?}")]
30    InvalidStateAction { action: Action, state: State },
31
32    #[error("Simulation Error: Invalid action id {id:?}")]
33    InvalidActionId { id: usize },
34
35    #[error("Simulation Error: Move out of bounds to ({x}, {y})")]
36    OutOfBounds { x: isize, y: isize },
37}