HTTP/ErrorList.pm

filter: Statementstmt 88.1% 37 / 42 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 82.5% 52 / 63 CC 5 SCAR 8.4
CC
5
Cov
82%
err
4.7
__ANON__
2.0
BEGIN
1.0
CRAP 2.3
« HTTP/AllError.pm ↑ Summary HTTP/Error.pm »
1 package Error::Pure::HTTP::ErrorList;
2  
3 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Error::Pure::Utils qw(err_helper);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Error::Pure::Output::Text qw(err_line_all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use List::MoreUtils qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # Constants.
13 3 Readonly::Array our @EXPORT_OK => qw(err);
14 3 Readonly::Scalar my $EVAL => 'eval {...}';
15  
16 # Version.
17 3 our $VERSION = 0.15;
18  
19 # Ignore die signal.
20 3 $SIG{__DIE__} = 'IGNORE';
21  
22 # Process error.
23 sub err {
24 5 ▶ my @msg = @_;
Subroutine err: called CC=4 SCAR=15.6
Pod documented
25  
26 # Get errors structure.
27 5 my @errors = err_helper(@msg);
28  
29 # Finalize in main on last err.
30 5 my $stack_ar = $errors[-1]->{'stack'};
31 5 ▶ if ($stack_ar->[-1]->{'class'} eq 'main'
Branch: 1 branch
BranchTrueFalseTotal
if ($stack_ar->[-1]{'class'} eq 'main' and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{'sub'};} @{$stack_ar;}))) { } 0 5 5
Condition33%1/3
$stack_ar->[-1]{"class"} eq "main" and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
!ll&&!rl&&r
050
MC/DC0%0/2
$stack_ar->[-1]{"class"} eq "main" and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
$stack_ar->[-1]{"class"} eq "main" &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
Truth table33%1/3
A and B
A= $stack_ar->[-1]{"class"} eq "main"B= &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
ABresult
0X0
100
111
32 10 ▶ && none { $_ eq $EVAL || $_ =~ /^eval '/ms }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $EVAL or $_ =~ /^eval '/ms 5 5 10
33 10 map { $_->{'sub'} } @{$stack_ar}) {
34  
35 0 print "Content-type: text/plain\n\n";
36 0 print err_line_all(@errors);
37 0 return;
38  
39 # Die for eval.
40 } else {
41 5 my $e = $errors[-1]->{'msg'}->[0];
42 5 ▶ if (! defined $e) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $e) { } 0 5 5
43 0 $e = 'undef';
44 } else {
45 5 chomp $e;
46 }
47 5 die "$e\n";
48 }
49  
50 0 return;
51 }
52  
53 3 1;
54  
55 __END__
« HTTP/AllError.pm ↑ Summary HTTP/Error.pm »