| 1 | package Error::Pure::JSON::Advance; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Pragmas. | ||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # Modules. | ||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Error::Pure::Output::JSON qw(err_json); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Error::Pure::Utils qw(err_helper); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use List::MoreUtils qw(none); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Constants. | ||||||||||||||||||||||||||||
| 15 | 6 | Readonly::Array our @EXPORT_OK => qw(err); | |||||||||||||||||||||||||||
| 16 | 6 | Readonly::Scalar my $EVAL => 'eval {...}'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Version. | ||||||||||||||||||||||||||||
| 19 | 6 | our $VERSION = 0.06; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Global variables. | ||||||||||||||||||||||||||||
| 22 | 6 | our %ERR_PARAMETERS; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # Ignore die signal. | ||||||||||||||||||||||||||||
| 25 | 6 | $SIG{__DIE__} = 'IGNORE'; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # Process error. | ||||||||||||||||||||||||||||
| 28 | sub err { | ||||||||||||||||||||||||||||
| 29 | 7 | ▶ | my @msg = @_; | ||||||||||||||||||||||||||
|
Subroutine
err: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # Get errors structure. | ||||||||||||||||||||||||||||
| 32 | 7 | my @errors = err_helper(@msg); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # Finalize in main on last err. | ||||||||||||||||||||||||||||
| 35 | 7 | my $stack_ar = $errors[-1]->{'stack'}; | |||||||||||||||||||||||||||
| 36 | 7 | ▶ | if ($stack_ar->[-1]->{'class'} eq 'main' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$stack_ar->[-1]{"class"} eq "main" and &none(sub {
$_ eq $EVAL or $_ =~ /^eval '/ms;
}
, map({$_->{"sub"};} @{$stack_ar;}))
MC/DC50%1/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 table66%2/3
A and B
A= $stack_ar->[-1]{"class"} eq "main"B= &none(sub {
$_ eq $EVAL or $_ =~ /^eval '/ms;
}
, map({$_->{"sub"};} @{$stack_ar;}))
| |||||||||||||||||||||||||||||
| 37 | 12 | ▶ | && none { $_ eq $EVAL || $_ =~ /^eval '/ms } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 12 | map { $_->{'sub'} } @{$stack_ar}) { | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2 | my $err_hr = { | |||||||||||||||||||||||||||
| 41 | 'error-pure' => \@errors, | ||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||
| 43 | 2 | foreach my $key (keys %ERR_PARAMETERS) { | |||||||||||||||||||||||||||
| 44 | 0 | $err_hr->{$key} = $ERR_PARAMETERS{$key}; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 2 | die err_json($err_hr)."\n"; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # Die for eval. | ||||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||
| 50 | 5 | die "$errors[-1]->{'msg'}->[0]\n"; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | return; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 6 | 1; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||