blib/lib/Dancer/Exception/Base.pm

filter: Statementstmt 97.1% 69 / 71 Branchbran 80.0% 8 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 89.4% 17 / 19 Podpod 83.3% 5 / 6 totaltotal 87.0% 101 / 116 SCAR 20.9
CC
8
Cov
91%
__ANON__
8.1
__ANON__
2.0
_message_pattern
2.0
CRAP 8.0
« blib/lib/Dancer/Hook.pm ↑ Summary blib/lib/Dancer/Serializer/YAML.pm »
1 package Dancer::Exception::Base;
2 266 our $AUTHORITY = 'cpan:SUKRIA';
3 #ABSTRACT: the base class of all Dancer exceptions
4 266 $Dancer::Exception::Base::VERSION = '1.3520';
5 266 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 266 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 266 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 266 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 266 ▶use Dancer::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 use overload '""' => sub {
14 58 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
15 $self->message
16 58 ▶ . ( $Dancer::Exception::Verbose ? $self->{_longmess} : $self->{_shortmess});
Branch: 1 branch
BranchTrueFalseTotal
$Dancer::Exception::Verbose ? : 2 56 58
17 266 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # string comparison is done without the stack traces
20 use overload 'cmp' => sub {
21 2 ▶ my ($e, $f) = @_;
Subroutine __ANON__: called CC=5 SCAR=20.9
22 2 ▶ ( ref $e && $e->isa(__PACKAGE__)
Branch: 2 branches
BranchTrueFalseTotal
ref $e && $e->isa(__PACKAGE__) ? : 2 0 2
ref $f && $f->isa(__PACKAGE__) ? : 0 2 2
Condition33%2/6
ref $e and $e->isa(__PACKAGE__)
!ll&&!rl&&r
002
ref $f and $f->isa(__PACKAGE__)
!ll&&!rl&&r
200
MC/DC0%0/2
ref $e and $e->isa(__PACKAGE__)
ref $e $e->isa(__PACKAGE__)
MC/DC0%0/2
ref $f and $f->isa(__PACKAGE__)
ref $f $f->isa(__PACKAGE__)
Truth table33%1/3
A and B
A= ref $eB= $e->isa(__PACKAGE__)
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= ref $fB= $f->isa(__PACKAGE__)
ABresult
0X0
100
111
23 ? $e->message : $e )
24 cmp
25 ( ref $f && $f->isa(__PACKAGE__)
26 ? $f->message : $f )
27 266 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 # This is the base class of all exceptions
30  
31 sub new {
32 41 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
33 41 my $self = bless { _raised_arguments => [],
34 _shortmess => '',
35 _longmess => '',
36 }, $class;
37 41 $self->_raised_arguments(@_);
38 41 return $self;
39 }
40  
41 # base class has a passthrough message
42 0 ▶sub _message_pattern { '%s' }
Subroutine _message_pattern: not called CC=1 SCAR=6.9
43  
44 sub throw {
45 41 ▶ my $self = shift;
Subroutine throw: called CC=1 SCAR=0.0
Pod documented
46 41 $self->_raised_arguments(@_);
47 41 local $Carp::CarpInternal;
48 41 local $Carp::Internal;
49 41 $Carp::Internal{'Dancer'} ++;
50 41 $Carp::CarpInternal{'Dancer::Exception'} ++;
51 41 $self->{_shortmess} = Carp::shortmess;
52 41 $self->{_longmess} = Carp::longmess;
53 41 die $self;
54 }
55  
56 0 ▶sub rethrow { die $_[0] }
Subroutine rethrow: not called CC=1 SCAR=6.9
Pod documented
57  
58 sub message {
59 60 ▶ my ($self) = @_;
Subroutine message: called CC=1 SCAR=0.0
Pod documented
60 60 my $message_pattern = $self->_message_pattern;
61 60 my $message = sprintf($message_pattern, @{$self->_raised_arguments});
62 60 return $message;
63 }
64  
65 sub does {
66 5 ▶ my $self = shift;
Subroutine does: called CC=1 SCAR=0.0
Pod documented
67 5 my $regexp = join('|', map { '^' . $_ . '$'; } @_);
68 5 (scalar grep { /$regexp/ } $self->get_composition) >= 1;
69 }
70  
71 sub get_composition {
72 6 ▶ my ($self) = @_;
Subroutine get_composition: called CC=1 SCAR=0.0
Pod documented
73 6 my $class = ref($self);
74  
75 6 my ($_recurse_isa, %seen);
76 $_recurse_isa = sub {
77 34 ▶ my ($class) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
78 34 ▶ $seen{$class}++
Branch: 1 branch
BranchTrueFalseTotal
$seen{$class}++ and return 11 23 34
79 and return;
80  
81 266 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
82 28 return $class, map { $_recurse_isa->($_) }
83 34 grep { /^Dancer::Exception::/ }
84 23 @{"${class}::ISA"};
85
86 6 };
87 6 grep { s/^Dancer::Exception::// } $_recurse_isa->($class);
88 }
89  
90 sub _raised_arguments {
91 142 ▶ my $self = shift;
Subroutine _raised_arguments: called CC=2 SCAR=6.9
92 142 ▶ @_ and $self->{_raised_arguments} = [ @_ ];
Branch: 1 branch
BranchTrueFalseTotal
@_ and $self->{"_raised_arguments"} = [@_] 41 101 142
93 142 $self->{_raised_arguments};
94 }
95  
96 266 1;
97  
98 __END__
« blib/lib/Dancer/Hook.pm ↑ Summary blib/lib/Dancer/Serializer/YAML.pm »