File Coverage

blib/lib/EO/Error.pm
Criterion Covered Total %
statement 15 45 33.3
branch 0 8 0.0
condition 0 2 0.0
subroutine 5 10 50.0
pod 2 3 66.6
total 22 68 32.3


line stmt bran cond sub pod time code
1             package EO::Error;
2              
3 18     18   93 use strict;
  18         33  
  18         556  
4 18     18   112 use warnings;
  18         27  
  18         427  
5              
6 18     18   96 use EO;
  18         48  
  18         607  
7 18     18   25541 use Error;
  18         149572  
  18         111  
8              
9             our $VERSION = 0.96;
10             our $SILENTLY_REDEFINE_EXCEPTIONS = 1;
11             our @ISA = qw(Error);
12              
13             sub new {
14 0     0 1   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             our $AUTOLOAD;
26             sub AUTOLOAD {
27 0     0     my $self = shift;
28 0           my $meth = substr($AUTOLOAD, rindex($AUTOLOAD, ':') + 1);
29 0 0         if (defined($self->{"-$meth"})) {
30 0 0         if (@_) {
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     0     sub DESTROY {}
41              
42             ##
43             ## we actually want a stack trace if we have to stringify.
44             ##
45             sub stringify {
46 0     0 1   my $self = shift;
47 0           "[".ref($self)."] - ".$self->stacktrace;
48             }
49              
50             ##
51             ## this is a neat way of creating declarations
52             ##
53             sub UNIVERSAL::exception {
54 0     0 0   my $class = shift;
55             ## it would be much nicer to use EO::Class here, but we
56             ## can't really. Not yet.
57 0 0         if (UNIVERSAL::can($class, 'can')) {
58 0 0         if (!$EO::Error::SILENTLY_REDEFINE_EXCEPTIONS) {
59 0           require Carp;
60 0           Carp::carp("not redefining exception class $class");
61             }
62 0           return;
63             }
64 0           my $args = { @_ };
65 0   0       my $parent = $args->{extends} || 'EO::Error';
66             {
67 18     18   9289 no strict 'refs';
  18         70  
  18         1561  
  0            
68 0           @{ $class . '::ISA' } = ( $parent );
  0            
69             }
70             }
71              
72             1;
73              
74             __END__