| 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
| |||||||||||||
| 30 | 0 | ▶ | if (@_) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 58 | 148 | ▶ | if (!$EO::Error::SILENTLY_REDEFINE_EXCEPTIONS) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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'
MC/DC0%0/1
$args->{'extends'} || 'EO::Error'
$args->{'extends'}
Truth table0%0/2
A
A= $args->{'extends'}
| |||||||||||||
| 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__ | ||||||||||||