NAME

Game::Schnapsen::Error - what the rules refuse, as a code

VERSION

Version 0.01

SYNOPSIS

my $bad = Game::Schnapsen::Variant::check_variant('bezique');
if ($bad) {
    $bad->code;       # 'bad_variant'
    $bad->message;    # 'that is not a game this engine plays'
}

DESCRIPTION

The engine returns its refusals rather than throwing them, so a caller decides what its users read. die is reserved for programmer error: a card id that is not a card, or a variant name that reached a rules function without being checked at the boundary.

The code is the part a caller should branch on. A consumer maps these to its own vocabulary, and should map an unknown code to its most general refusal rather than letting it escape, so that a code added here later degrades instead of crashing.

METHODS

new_code

Game::Schnapsen::Error->new_code('bad_variant');

Builds an error from a code, filling in the message.

code

The short code.

message

A sentence, for a terminal.

codes

Every code this class knows, sorted. A caller mapping codes to its own vocabulary can use this to check it has covered them all.

AUTHOR

LNATION, <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under the Artistic License 2.0.