blib/lib/Games/TF2/Demo/Error.pm

filter: Statementstmt 85.1% 23 / 27 Branchbran 50.0% 2 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 75.0% 33 / 44 CC 3 SCAR 11.0
CC
3
Cov
76%
kind
6.0
throw_status
6.0
BEGIN
1.0
CRAP 3.0
« blib/lib/Games/TF2/Demo/Iterator.pm ↑ Summary blib/lib/Games/TF2/Demo/Vector.pm »
1 package Games::TF2::Demo::Error;
2  
3 12 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 our $VERSION = '0.01';
9  
10 12 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 12 ▶use Exception::Class (
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 'Games::TF2::Demo::Error',
14 'Games::TF2::Demo::Error::IO' => { isa => 'Games::TF2::Demo::Error' },
15 'Games::TF2::Demo::Error::Truncated' => { isa => 'Games::TF2::Demo::Error' },
16 'Games::TF2::Demo::Error::Malformed' => { isa => 'Games::TF2::Demo::Error' },
17 'Games::TF2::Demo::Error::Unsupported' => { isa => 'Games::TF2::Demo::Error' },
18 'Games::TF2::Demo::Error::State' => { isa => 'Games::TF2::Demo::Error' },
19 'Games::TF2::Demo::Error::Argument' => { isa => 'Games::TF2::Demo::Error' },
20 'Games::TF2::Demo::Error::Internal' => { isa => 'Games::TF2::Demo::Error' },
21 'Games::TF2::Demo::Error::Network' => { isa => 'Games::TF2::Demo::Error' },
22 'Games::TF2::Demo::Error::Timeout' => { isa => 'Games::TF2::Demo::Error' },
23 'Games::TF2::Demo::Error::Rejected' => { isa => 'Games::TF2::Demo::Error' },
24 12 );
25  
26 # The kind of each tfdemo_status error of tfdemo.h; its class is the kind
27 # with a capital (IO in capitals).
28 12 Readonly my %KIND_OF_STATUS => (
29 1 => 'io',
30 2 => 'truncated',
31 3 => 'malformed',
32 4 => 'unsupported',
33 5 => 'state',
34 6 => 'argument',
35 7 => 'internal',
36 8 => 'network',
37 9 => 'timeout',
38 10 => 'rejected',
39 );
40 12 ▶Readonly my %CLASS_OF_KIND => map { $_ => __PACKAGE__ . '::' . ( $_ eq 'io' ? 'IO' : ucfirst ) } values %KIND_OF_STATUS;
Branch: 1 branch
BranchTrueFalseTotal
$_ eq 'io' ? : 12 108 120
41 12 Readonly my %KIND_OF_CLASS => reverse %CLASS_OF_KIND;
42  
43 0 ▶sub kind ($self) {
Subroutine kind: not called CC=2 SCAR=17.9
Pod documented
44 0 ▶ return $KIND_OF_CLASS{ ref $self } // 'error';
Condition0%0/2
$KIND_OF_CLASS{ref $self} // "error"
l!l
00
MC/DC0%0/1
$KIND_OF_CLASS{ref $self} // "error"
$KIND_OF_CLASS{ref $self}
Truth table0%0/2
A
A= $KIND_OF_CLASS{ref $self}
Aresult
11
00
45 }
46  
47 # Throws the error of a tfdemo_status with the library's message. A status
48 # tfdemo.h does not define is an internal error.
49 0 ▶sub throw_status ( $class, $status, $message ) {
Subroutine throw_status: not called CC=2 SCAR=17.9
Pod documented
50 0 my $kind = $KIND_OF_STATUS{$status};
51 0 ▶ die Games::TF2::Demo::Error::Internal->new( message => "unknown tfdemo_status $status: $message" ) unless defined $kind;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $kind 0 0 0
52 0 die $CLASS_OF_KIND{$kind}->new( message => $message );
53 }
54  
55 12 1;
56  
57 __END__
« blib/lib/Games/TF2/Demo/Iterator.pm ↑ Summary blib/lib/Games/TF2/Demo/Vector.pm »