NAME

Game::Backgammon::Error - what the rules refuse, with a code

SYNOPSIS

my $turn = $game->play('8/5 6/5');
if (!$turn) {
    my $e = $@;
    $e->code;        # 'not_legal'
    $e->message;     # 'the rules do not offer that turn'
}

DESCRIPTION

The engine returns its refusals rather than throwing them, so a caller can map code onto its own vocabulary. die is reserved for programmer error: a malformed position, a bad argument.

METHODS

code

The machine-readable reason.

detail

Whatever extra the refusal carried, or undef.

message

One sentence for a person, with the detail appended when there is one.

stringify

code: message.