| 1 | package Error::Pure::HTTP::AllError; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Pragmas. | ||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # Modules. | ||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Error::Pure::Utils qw(err_helper); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Error::Pure::Output::Text qw(err_bt_pretty); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use List::MoreUtils qw(none); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Constants. | ||||||||||||||||||||||||||||
| 15 | 3 | Readonly::Array our @EXPORT_OK => qw(err); | |||||||||||||||||||||||||||
| 16 | 3 | Readonly::Scalar my $EVAL => 'eval {...}'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Version. | ||||||||||||||||||||||||||||
| 19 | 3 | our $VERSION = 0.14; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Ignore die signal. | ||||||||||||||||||||||||||||
| 22 | 3 | $SIG{__DIE__} = 'IGNORE'; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # Process error. | ||||||||||||||||||||||||||||
| 25 | sub err { | ||||||||||||||||||||||||||||
| 26 | 5 | ▶ | my @msg = @_; | ||||||||||||||||||||||||||
|
Subroutine
err: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # Get errors structure. | ||||||||||||||||||||||||||||
| 29 | 5 | my @errors = err_helper(@msg); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # Finalize in main on last err. | ||||||||||||||||||||||||||||
| 32 | 5 | my $stack_ar = $errors[-1]->{'stack'}; | |||||||||||||||||||||||||||
| 33 | 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;}))
| |||||||||||||||||||||||||||||
| 34 | 10 | ▶ | && none { $_ eq $EVAL || $_ =~ m/^eval '/ms } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 10 | map { $_->{'sub'} } @{$stack_ar}) { | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | print "Content-type: text/plain\n\n"; | |||||||||||||||||||||||||||
| 38 | 0 | print scalar err_bt_pretty(@errors); | |||||||||||||||||||||||||||
| 39 | 0 | return; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Die for eval. | ||||||||||||||||||||||||||||
| 42 | } else { | ||||||||||||||||||||||||||||
| 43 | 5 | my $e = $errors[-1]->{'msg'}->[0]; | |||||||||||||||||||||||||||
| 44 | 5 | ▶ | if (! defined $e) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | $e = 'undef'; | |||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||
| 47 | 5 | chomp $e; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 5 | die "$e\n"; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | return; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 3 | 1; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||