Pure.pm

filter: Statementstmt 88.6% 39 / 44 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 87.1% 54 / 62 SCAR 18.1
CC
6
Cov
85%
err
6.8
BEGIN
1.0
BEGIN
1.0
CRAP 6.1
« Pure/Utils.pm ↑ Summary Pure/AllError.pm »
1 package Error::Pure;
2  
3 5 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Error::Pure::Utils qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Constants.
12 5 Readonly::Array our @EXPORT_OK => qw(err);
13 5 Readonly::Scalar my $TYPE_DEFAULT => 'Die';
14 5 Readonly::Scalar my $LEVEL_DEFAULT => 4;
15  
16 5 our $VERSION = 0.30;
17  
18 # Type of error.
19 5 our $TYPE;
20  
21 # Level for this class.
22 5 our $LEVEL = $LEVEL_DEFAULT;
23  
24 # Process error.
25 sub err {
26 9 ▶ my @msg = @_;
Subroutine err: called CC=6 SCAR=19.1
Pod documented
27 9 $Error::Pure::Utils::LEVEL = $LEVEL;
28 9 my $class;
29 9 ▶ if (defined $TYPE) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $Error::Pure::TYPE) { } 5 4 9
elsif ($ENV{'ERROR_PURE_TYPE'}) { } 0 4 4
30 5 $class = 'Error::Pure::'.$TYPE;
31 } elsif ($ENV{'ERROR_PURE_TYPE'}) {
32 $class = 'Error::Pure::'.
33 0 $ENV{'ERROR_PURE_TYPE'};
34 } else {
35 4 $class = 'Error::Pure::'.$TYPE_DEFAULT;
36 }
37 9 eval "require $class";
38 9 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Error::Pure::EVAL_ERROR) 1 8 9
39  
40 # Switch to default, module doesn't exist.
41 1 $class = 'Error::Pure::'.$TYPE_DEFAULT;
42 1 eval "require $class";
43 1 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Error::Pure::EVAL_ERROR) 0 1 1
44 0 my $err = $EVAL_ERROR;
45 0 $err =~ s/\ at.*$//ms;
46 0 die $err;
47 }
48 }
49 9 eval $class.'::err @msg';
50 9 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Error::Pure::EVAL_ERROR) 9 0 9
51 9 die $EVAL_ERROR;
52 }
53 0 return;
54 }
55  
56 5 1;
57  
58 __END__
« Pure/Utils.pm ↑ Summary Pure/AllError.pm »