blib/lib/Error/Pure/NoDie.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 96.3% 53 / 55 SCAR 13.9
CC
4
Cov
98%
err
3.0
__ANON__
2.0
BEGIN
1.0
CRAP 4.0
↑ Summary
1 package Error::Pure::NoDie;
2  
3 # Pragmas.
4 4 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Modules.
9 4 ▶use Error::Pure::Utils qw(err_helper);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use List::MoreUtils qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Version.
14 4 our $VERSION = 0.03;
15  
16 # Constants.
17 4 Readonly::Array our @EXPORT_OK => qw(err);
18 4 Readonly::Scalar my $EMPTY_STR => q{};
19 4 Readonly::Scalar my $EVAL => 'eval {...}';
20  
21 # Ignore die signal.
22 4 $SIG{__DIE__} = 'IGNORE';
23  
24 # Process error.
25 sub err {
26 7 ▶ my @msg = @_;
Subroutine err: called CC=3 SCAR=11.0
Pod documented
27  
28 # Get errors structure.
29 7 my @errors = err_helper(@msg);
30  
31 # Error messages.
32 7 chomp $errors[-1]->{'msg'}->[0];
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
BranchTrueFalseTotal
if ($stack_ar->[-1]{'class'} eq 'main' and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{'sub'};} @{$stack_ar;}))) { } 2 5 7
Condition66%2/3
$stack_ar->[-1]{"class"} eq "main" and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
!ll&&!rl&&r
052
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;}))
ABresult
0X0
100
111
37 13 ▶ && none { $_ eq $EVAL || $_ =~ /^eval '/ms }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $EVAL or $_ =~ /^eval '/ms 8 5 13
38 13 map { $_->{'sub'} } @{$stack_ar}) {
39  
40 2 print join $EMPTY_STR, @{$errors[-1]->{'msg'}}, "\n";
41  
42 # Die for eval.
43 } else {
44 5 my $e = $errors[-1]->{'msg'}->[0];
45 5 die "$e\n";
46 }
47  
48 2 return;
49 }
50  
51 4 1;
52  
53 __END__
↑ Summary