NAME
Game::Snake::Error - a refused turn, returned rather than thrown
VERSION
Version 0.13
SYNOPSIS
$game->turn('right') or do {
my $error = $game->error;
print $error->code; # reverse
print $error->message; # a snake cannot turn back on itself
};
DESCRIPTION
Game::Snake refuses a turn by returning 0 and keeping one of these where "error" in Game::Snake can find it. Nothing is thrown: a refused turn is an ordinary thing to happen in a game, not an error in the program.
The codes are same_direction, reverse and not_active.
METHODS
of
my $error = Game::Snake::Error->of('reverse');
Builds the error for a code. An unknown code is a programmer error and dies.
code, message, error
The code, its sentence, and 1.
codes, messages
Every code, and every code with its sentence.
stringify
The code and the sentence, joined with a colon.
AUTHOR
LNATION, <email at lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2024 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)