| 1 | package Game::Sternhalma::Error; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 30 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 30 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | use overload '""' => sub { $_[0]->message }, bool => sub { 1 }, fallback => 1; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 30 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | # A PROGRAMMER'S MISTAKE, NOT A PLAYER'S. A move that is not allowed is a flag | ||||||||||||||||||||||||||||||||
| 13 | # Game::Sternhalma::play returns; this is what a constructor or replay dies | ||||||||||||||||||||||||||||||||
| 14 | # with when it was given something no game can be made of. A plain blessed | ||||||||||||||||||||||||||||||||
| 15 | # hash: it needs no accessors made for it, and overloading is simplest there. | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 30 | our %CODE = ( | |||||||||||||||||||||||||||||||
| 18 | bad_layout => 1, | ||||||||||||||||||||||||||||||||
| 19 | bad_first => 1, | ||||||||||||||||||||||||||||||||
| 20 | bad_cap => 1, | ||||||||||||||||||||||||||||||||
| 21 | bad_log => 1, | ||||||||||||||||||||||||||||||||
| 22 | bad_position => 1, | ||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 15 | ▶ | sub throw { | ||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=7 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 26 | 15 | my ($class, $code, $detail) = @_; | |||||||||||||||||||||||||||||||
| 27 | Carp::croak("Game::Sternhalma::Error: no such error as '" . (defined $code ? $code : 'undef') . "'") | ||||||||||||||||||||||||||||||||
| 28 | 15 | ▶ | unless defined $code && $CODE{$code}; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $code and $Game::Sternhalma::Error::CODE{$code}
MC/DC50%1/2
defined $code and $Game::Sternhalma::Error::CODE{$code}
defined $code
$Game::Sternhalma::Error::CODE{$code}
Truth table66%2/3
A and B
A= defined $codeB= $Game::Sternhalma::Error::CODE{$code}
| |||||||||||||||||||||||||||||||||
| 29 | 14 | my ($pkg, $file, $line) = caller(1); | |||||||||||||||||||||||||||||||
| 30 | 14 | ▶ | ($file, $line) = (caller(0))[1, 2] unless defined $file; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 31 | 14 | ▶ | my $self = bless { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 32 | code => $code, | ||||||||||||||||||||||||||||||||
| 33 | detail => defined $detail ? $detail : '', | ||||||||||||||||||||||||||||||||
| 34 | message => "Game::Sternhalma: $code: " . (defined $detail ? $detail : '') . " at $file line $line.\n", | ||||||||||||||||||||||||||||||||
| 35 | }, $class; | ||||||||||||||||||||||||||||||||
| 36 | 14 | die $self; | |||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 12 | ▶ | sub code { $_[0]{code} } | ||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub detail { $_[0]{detail} } | ||||||||||||||||||||||||||||||
|
Subroutine
detail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 41 | 22 | ▶ | sub message { $_[0]{message} } | ||||||||||||||||||||||||||||||
|
Subroutine
message: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | sub codes { sort keys %CODE } | ||||||||||||||||||||||||||||||
|
Subroutine
codes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 30 | 1; | |||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||||||