EO/Error.pm

filter: Statementstmt 48.9% 24 / 49 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 60.0% 6 / 10 Podpod 66.6% 2 / 3 totaltotal 46.5% 34 / 73 CC 7 SCAR 16.4
CC
7
Cov
44%
AUTOLOAD
12.0
exception
6.7
new
6.0
CRAP 5.2
« EO/Hierarchy.pm ↑ Summary EO/Message.pm »
1 package EO::Error;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use EO;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 18 our $VERSION = 0.96;
10 18 our $SILENTLY_REDEFINE_EXCEPTIONS = 1;
11 18 our @ISA = qw(Error);
12  
13 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
14 0 my $class = shift;
15 0 my %params = @_;
16 0 my %new_params;
17 0 local($Error::Depth) = $Error::Depth + 1;
18 0 local($Error::Debug) = 1;
19 0 foreach my $key (keys %params) {
20 0 $new_params{"-$key"} = $params{$key};
21 }
22 0 $class->SUPER::new(%new_params);
23 }
24  
25 18 our $AUTOLOAD;
26 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
27 0 my $self = shift;
28 0 my $meth = substr($AUTOLOAD, rindex($AUTOLOAD, ':') + 1);
29 0 ▶ if (defined($self->{"-$meth"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$self{"-$meth"}) 0 0 0
30 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
31 0 $self->{"-$meth"} = shift;
32 0 return $self;
33 }
34 0 return $self->{"-$meth"};
35 }
36 throw EO::Error::Method::NotFound
37 0 text => "no such property $meth defined on this error";
38 }
39  
40 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
41  
42 ##
43 ## we actually want a stack trace if we have to stringify.
44 ##
45 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
46 0 my $self = shift;
47 0 "[".ref($self)."] - ".$self->stacktrace;
48 }
49  
50 ##
51 ## this is a neat way of creating declarations
52 ##
53 148 ▶sub UNIVERSAL::exception {
Subroutine exception: called CC=4 SCAR=19.0
Pod undocumented
54 148 my $class = shift;
55 ## it would be much nicer to use EO::Class here, but we
56 ## can't really. Not yet.
57 148 ▶ if (UNIVERSAL::can($class, 'can')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::can($class, "can")) 148 0 148
58 148 ▶ if (!$EO::Error::SILENTLY_REDEFINE_EXCEPTIONS) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($EO::Error::SILENTLY_REDEFINE_EXCEPTIONS) 0 148 148
59 0 require Carp;
60 0 Carp::carp("not redefining exception class $class");
61 }
62 148 return;
63 }
64 0 my $args = { @_ };
65 0 ▶ my $parent = $args->{extends} || 'EO::Error';
Condition0%0/2
$args->{'extends'} || 'EO::Error'
l!l
00
MC/DC0%0/1
$args->{'extends'} || 'EO::Error'
$args->{'extends'}
Truth table0%0/2
A
A= $args->{'extends'}
Aresult
11
00
66 {
67 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
68 0 @{ $class . '::ISA' } = ( $parent );
69 }
70 }
71  
72 18 1;
73  
74 __END__
« EO/Hierarchy.pm ↑ Summary EO/Message.pm »