| 1 | package Error::Pure::Die; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Error::Pure::Utils qw(err_helper); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use List::Util qw(none); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 7 | our $VERSION = 0.30; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 7 | Readonly::Array our @EXPORT_OK => qw(err); | |||||||||||||||||||||||||||
| 14 | 7 | Readonly::Scalar my $EVAL => 'eval {...}'; | |||||||||||||||||||||||||||
| 15 | 7 | Readonly::Scalar my $EMPTY_STR => q{}; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Process error. | ||||||||||||||||||||||||||||
| 18 | sub err { | ||||||||||||||||||||||||||||
| 19 | 16 | ▶ | my @msg = @_; | ||||||||||||||||||||||||||
|
Subroutine
err: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Get errors structure. | ||||||||||||||||||||||||||||
| 22 | 16 | my @errors = err_helper(@msg); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # Finalize in main on last err. | ||||||||||||||||||||||||||||
| 25 | 16 | my $stack_ar = $errors[-1]->{'stack'}; | |||||||||||||||||||||||||||
| 26 | 16 | ▶ | 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;}))
| |||||||||||||||||||||||||||||
| 27 | 30 | ▶ | && none { $_ eq $EVAL || $_ =~ /^eval '/ms } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 30 | map { $_->{'sub'} } @{$stack_ar}) { | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | my $die = (join $EMPTY_STR, @{$errors[-1]->{'msg'}}). | |||||||||||||||||||||||||||
| 31 | " at $stack_ar->[0]->{'prog'} line ". | ||||||||||||||||||||||||||||
| 32 | "$stack_ar->[0]->{'line'}."; | ||||||||||||||||||||||||||||
| 33 | 2 | die "$die\n"; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Die for eval. | ||||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||
| 37 | 14 | die "$errors[-1]->{'msg'}->[0]\n"; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | return; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 7 | 1; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||