blib/lib/Sub/Exception.pm

filter: Statementstmt 100% 25 / 25 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 97.2% 35 / 36 CC 3 SCAR 4.1
CC
3
Cov
97%
__ANON__
2.0
import
2.0
export
1.0
CRAP 1.5
↑ Summary
1 package Sub::Exception;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.01';
6  
7 1 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
8 1 my ($class, %args) = @_;
9  
10 1 my $caller = caller;
11  
12 1 ▶ while (my ($fn, $handler) = each %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 2 1 3
13 2 $class->export(
14 name => $fn,
15 error_handler => $handler,
16 package => $caller,
17 );
18 }
19 }
20  
21 2 ▶sub export {
Subroutine export: called CC=1 SCAR=0.0
Pod documented
22 2 my ($class, %args) = @_;
23  
24 2 my $name = $args{name};
25 my $error_handler = $args{error_handler},
26 2 my $pkg = $args{package};
27  
28 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 ▶ *{"$pkg\::$name"} = sub (&) {
Subroutine __ANON__: called CC=2 SCAR=7.0
30 2 my ($sub) = @_;
31  
32 2 eval {
33 2 $sub->();
34 };
35 2 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 2 0 2
36 2 $error_handler->($_ = $@);
37 }
38 2 };
39 }
40  
41 1 1;
42  
43 __END__
↑ Summary