blib/lib/Exception/Class/Try/Catch.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 6 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 98.3% 59 / 60 CC 5 SCAR 8.9
CC
5
Cov
100%
__ANON__
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
↑ Summary
1 # Copyright (c) 2017 by Pali <pali@cpan.org>
2  
3 package Exception::Class::Try::Catch;
4  
5 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.1';
10  
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Exception::Class::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Exporter 5.57 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Try::Catch qw(try);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 $Carp::Internal{+__PACKAGE__} = 1;
18  
19 1 our @EXPORT_OK = qw(try catch);
20 1 our @EXPORT = @EXPORT_OK;
21  
22 sub catch (&;@) {
23 17 ▶ my $block = $_[0];
Subroutine catch: called CC=1 SCAR=0.0
Pod undocumented
24 $_[0] = sub {
25 15 ▶ my $error = $_[0];
Subroutine __ANON__: called CC=5 SCAR=16.1
26 15 ▶ if (Scalar::Util::blessed($error) and not $error->isa('Exception::Class::Base')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($error) and not $error->isa("Exception::Class::Base")) 3 12 15
Condition100%3/3
builtin::blessed($error) and not $error->isa("Exception::Class::Base")
!ll&&!rl&&r
573
MC/DC100%2/2
builtin::blessed($error) and not $error->isa("Exception::Class::Base")
builtin::blessed($error) not $error->isa("Exception::Class::Base")
Truth table100%3/3
A and not(B)
A= builtin::blessed($error)B= not $error->isa("Exception::Class::Base")
ABresult
0X0
100
111
27 3 ▶ $error = $error->as_string() if $error->can('as_string');
Branch: 1 branch
BranchTrueFalseTotal
if $error->can("as_string") 1 2 3
28 3 $error = "$error";
29 }
30 15 ▶ if (not Scalar::Util::blessed($error)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($error)) 8 7 15
31 8 $_[0] = $_ = Exception::Class::Base->new($error);
32 }
33 15 goto &$block;
34 17 };
35 17 goto &Try::Catch::catch;
36 }
37  
38 1 1;
39 __END__
↑ Summary