Postini/Exception.pm

filter: Statementstmt 90.2% 37 / 41 Branchbran 66.6% 8 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 80.0% 52 / 65 CC 9 SCAR 17.9
CC
9
Cov
80%
_initialize
9.5
cause
2.0
BEGIN
1.0
CRAP 6.0
« Postini.pm ↑ Summary Postini/Assert.pm »
1 package WWW::Postini::Exception;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 1 ▶use Exception::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 1 ▶use vars qw( @ISA $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 1 @ISA = qw( Exception::Class::Base );
11 1 $VERSION = '0.01';
12
13 #################
14 ## initializer ##
15 #################
16
17 3 ▶sub _initialize {
Subroutine _initialize: called CC=8 SCAR=22.5
18
19 3 my $self = shift;
20 3 my %params;
21
22 3 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 3 0 3
23
24 # passing an exception object as a cause
25
26 3 ▶ if (UNIVERSAL::isa($_[0], 'WWW::Postini::Exception')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($_[0], 'WWW::Postini::Exception')) { } 1 2 3
27
28 1 $params{'cause'} = shift;
29
30 # passing error text
31
32 } else {
33
34 2 $params{'error'} = shift;
35
36 }
37
38 } else {
39
40 0 %params = @_;
41
42 }
43
44 # cause object is defined
45
46 3 ▶ if (defined $params{'cause'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{'cause'}) { } 1 2 3
47
48 # set cause and remove parameter unsupported by base class
49 1 my $cause = $self->cause(delete $params{'cause'});
50
51 # call superclass initializer
52 1 $self->SUPER::_initialize(@_);
53
54 # prohibit superclass from using $! as the default message
55 1 ▶ $self->{'message'} = ref $cause unless defined $params{'message'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params{"message"} 1 0 1
56
57 1 my $trace = $self->trace();
58 1 my $cause_trace = $cause->trace();
59 1 my $frame_count = $trace->frame_count();
60
61 # strip any frames already present in cause stack trace
62
63 1 for my $idx (0..$frame_count - 1) {
64
65 3 my $frame = $trace->frame($idx);
66
67 3 ▶ if (grep $_->filename() eq $frame->filename()
Branch: 1 branch
BranchTrueFalseTotal
if (grep(($_->filename eq $frame->filename && $_->line == $frame->line), @{$$cause_trace{"frames"};})) 0 3 3
Condition0%0/3
$_->filename eq $frame->filename && $_->line == $frame->line
!ll&&!rl&&r
000
MC/DC0%0/2
$_->filename eq $frame->filename && $_->line == $frame->line
$_->filename eq $frame->filename $_->line == $frame->line
Truth table0%0/3
A && B
A= $_->filename eq $frame->filenameB= $_->line == $frame->line
ABresult
0X0
100
111
68 && $_->line() == $frame->line(),
69 3 @{$cause_trace->{'frames'}}
70 ) {
71
72 0 splice @{$trace->{'frames'}}, $idx;
73 0 last;
74
75 }
76
77 }
78
79 } else {
80
81 2 $self->SUPER::_initialize(%params);
82
83 }
84
85 }
86
87 ######################
88 ## accessor methods ##
89 ######################
90
91 # cause
92
93 1 ▶sub cause {
Subroutine cause: called CC=2 SCAR=7.0
Pod documented
94
95 1 my $self = shift;
96
97 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 0 1
98
99 1 $self->{'cause'} = shift
100
101 }
102
103 1 $self->{'cause'};
104
105 }
106
107 1 1;
108
109 __END__
« Postini.pm ↑ Summary Postini/Assert.pm »