HTTP/Print.pm

filter: Statementstmt 77.7% 35 / 45 Branchbran 40.0% 4 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 71.0% 49 / 69 CC 7 SCAR 17.2
CC
7
Cov
69%
err
11.3
__ANON__
2.0
BEGIN
1.0
CRAP 5.6
↑ Summary HTTP/AllError.pm »
1 package Error::Pure::HTTP::Print;
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 List::MoreUtils qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Constants.
12 3 Readonly::Array our @EXPORT_OK => qw(err);
13 3 Readonly::Scalar my $EMPTY_STR => q{};
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=6 SCAR=24.3
Pod documented
25  
26 # Get errors structure.
27 5 my @errors = err_helper(@msg);
28  
29 # Error message.
30 5 my $e = $errors[-1]->{'msg'}->[0];
31 5 ▶ if (! defined $e) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $e) { } 0 5 5
32 0 $e = 'undef';
33 } else {
34 5 chomp $e;
35 }
36  
37 # Finalize in main on last err.
38 5 my $stack_ar = $errors[-1]->{'stack'};
39 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
40 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
41 10 map { $_->{'sub'} } @{$stack_ar}) {
42  
43 0 my $class = $errors[-1]->{'stack'}->[0]->{'class'};
44 0 ▶ if ($class eq 'main') {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq "main") 0 0 0
45 0 $class = $EMPTY_STR
46 }
47 0 ▶ if ($class) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class) 0 0 0
48 0 $class .= ': ';
49 }
50 0 print "Content-type: text/plain\n\n";
51 0 print $class."$e\n";
52 0 return;
53  
54 # Die for eval.
55 } else {
56 5 die "$e\n";
57 }
58  
59 0 return;
60 }
61  
62 3 1;
63  
64 __END__
↑ Summary HTTP/AllError.pm »