File Coverage

blib/lib/Error/Hierarchy/Internal/AbstractMethod.pm
Criterion Covered Total %
statement 23 23 100.0
branch 1 2 50.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 33 34 97.0


line stmt bran cond sub pod time code
1 1     1   36 use 5.008;
  1         13  
  1         51  
2 1     1   6 use strict;
  1         2  
  1         51  
3 1     1   5 use warnings;
  1         3  
  1         60  
4              
5             package Error::Hierarchy::Internal::AbstractMethod;
6             BEGIN {
7 1     1   69 $Error::Hierarchy::Internal::AbstractMethod::VERSION = '1.103530';
8             }
9             # ABSTRACT: Exception for unimplemented methods
10 1     1   6 use parent qw(Error::Hierarchy::Internal Class::Accessor);
  1         2  
  1         10  
11             __PACKAGE__->mk_accessors(qw(method));
12 1     1   130 use constant default_message => 'called abstract method [%s]';
  1         2  
  1         70  
13 1     1   5 use constant PROPERTIES => ('method');
  1         8  
  1         136  
14              
15             sub init {
16 1     1 1 43 my $self = shift;
17              
18             # because we call SUPER::init(), which uses caller() to set
19             # package, filename and line of the exception, *plus* we don't want
20             # to report the abstract method that threw this exception itself,
21             # rather we want to report its caller, i.e. the one that called the
22             # abstract method. So we use +2.
23 1         2 local $Error::Depth = $Error::Depth + 2;
24 1 50       6 $self->method((caller($Error::Depth))[3]) unless defined $self->method;
25 1         473 $self->SUPER::init(@_);
26             }
27             1;
28              
29              
30             __END__