1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
use std::error::Error; use state::Move; use actions::Action; quick_error! { #[derive(Debug)] pub enum GameError { BadMove(err: Box<Error>) { description("move error") display("Error processing move: {}", err) } InvalidMove(game_move: Move) { description("invalid move") display("The current move is invalid: {:?}", game_move) } InvalidAction(action: Action) { description("invalid action") display("The current action is invalid: {:?}", action) } InvalidState { description("invalid state") display("Attempted to restore from an invalid game state.") } MoveNotAllowed { description("move not allowed") display("The current player is not allowed to make that move.") } UnauthorizedAction(id: u16, action: Action) { description("action not authorized") display("Player {} is not authorized to perform: {:?}", id, action) } FlowError(err: Box<Error>) { description("user flow method produced an error") display("A user-defined flow method produced an error: {:?}", err) } } }