NAME
Game::Shogi::Error - a refusal, returned and never thrown
SYNOPSIS
my $refusal = $game->play('5h4g');
if ($refusal) {
print $refusal->code, "\n"; # in_check
print $refusal->message, "\n"; # that would leave your king in check
}
DESCRIPTION
A refused move comes back as one of these. It is not thrown: a refused move is an ordinary thing for a player to do, and a caller should not have to wrap every move in an eval. die is kept for programmer error, such as a refusal code that does not exist. This is Game::Xiangqi's rule, kept.
CODES
In the order the board asks a move's faults, so a move with two gives the first: bad_move, not_your_piece, not_in_hand, cannot_reach, occupied, promote_not_allowed, promote_required, dead_piece, two_pawns, in_check, pawn_drop_mate. Then those only a game gives: game_over, not_your_turn, cannot_declare and nothing_to_undo.
ATTRIBUTES
code
The refusal, one of the codes above.
message
The refusal in words, as a player would read it, with the detail after a colon when there is one (cannot_declare says which condition failed).
METHODS
throw
Game::Shogi::Error->throw('game_over')
Makes a refusal and RETURNS it, the name Game::Xiangqi uses. Croaks for a code that does not exist.
of_fault
The refusal for one of Game::Shogi::Engine's FAULT_ codes, or undef for FAULT_OK.
codes
Every code, in order.
known
True for a code that exists.
message_for
The message for a code.
stringify
The message.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)