| 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
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # passing an exception object as a cause | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 3 | ▶ | if (UNIVERSAL::isa($_[0], 'WWW::Postini::Exception')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$_->filename eq $frame->filename && $_->line == $frame->line
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | $self->{'cause'} = shift | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 1 | $self->{'cause'}; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | 1; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||