| 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
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$stack_ar->[-1]{"class"} eq "main" and &none(sub {
$_ eq $EVAL or $_ =~ /^eval '/ms;
}
, map({$_->{"sub"};} @{$stack_ar;}))
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;}))
| |||||||||||||||||||||||||||||
| 40 | 10 | ▶ | && none { $_ eq $EVAL || $_ =~ /^eval '/ms } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 45 | 0 | $class = $EMPTY_STR | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ($class) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||