| 1 | package Dancer::Exception::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 275 | our $AUTHORITY = 'cpan:SUKRIA'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | #ABSTRACT: the base class of all Dancer exceptions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 275 | $Dancer::Exception::Base::VERSION = '1.3522'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 275 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 275 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 275 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 275 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 275 | ▶ | use Dancer::Exception; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 275 | ▶ | use overload '""' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 58 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | $self->message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 58 | ▶ | . ( $Dancer::Exception::Verbose ? $self->{_longmess} : $self->{_shortmess}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 275 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # string comparison is done without the stack traces | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 275 | ▶ | use overload 'cmp' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
Subroutine
__ANON__: called CC=5 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | my ($e, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | ( ref $e && $e->isa(__PACKAGE__) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
ref $e and $e->isa(__PACKAGE__)
ref $f and $f->isa(__PACKAGE__)
MC/DC0%0/2
ref $e and $e->isa(__PACKAGE__)
ref $e
$e->isa(__PACKAGE__)
MC/DC0%0/2
ref $f and $f->isa(__PACKAGE__)
ref $f
$f->isa(__PACKAGE__)
Truth table33%1/3
A and B
A= ref $eB= $e->isa(__PACKAGE__)
Truth table33%1/3
A and B
A= ref $fB= $f->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ? $e->message : $e ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | cmp | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ( ref $f && $f->isa(__PACKAGE__) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ? $f->message : $f ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 275 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # This is the base class of all exceptions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 41 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 41 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 41 | my $self = bless { _raised_arguments => [], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | _shortmess => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | _longmess => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 41 | $self->_raised_arguments(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 41 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # base class has a passthrough message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub _message_pattern { '%s' } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message_pattern: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 41 | ▶ | sub throw { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 41 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 41 | $self->_raised_arguments(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 41 | local $Carp::CarpInternal; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 41 | local $Carp::Internal; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 41 | $Carp::Internal{'Dancer'} ++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 41 | $Carp::CarpInternal{'Dancer::Exception'} ++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 41 | $self->{_shortmess} = Carp::shortmess; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 41 | $self->{_longmess} = Carp::longmess; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 41 | die $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub rethrow { die $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rethrow: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 60 | ▶ | sub message { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 60 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 60 | my $message_pattern = $self->_message_pattern; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 60 | my $message = sprintf($message_pattern, @{$self->_raised_arguments}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 60 | return $message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | ▶ | sub does { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
does: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | my $regexp = join('|', map { '^' . $_ . '$'; } @_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | (scalar grep { /$regexp/ } $self->get_composition) >= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | ▶ | sub get_composition { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_composition: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 6 | my $class = ref($self); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | my ($_recurse_isa, %seen); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 34 | ▶ | $_recurse_isa = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 34 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 34 | ▶ | $seen{$class}++ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 275 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 28 | return $class, map { $_recurse_isa->($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 34 | grep { /^Dancer::Exception::/ } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 23 | @{"${class}::ISA"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 6 | grep { s/^Dancer::Exception::// } $_recurse_isa->($class); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 142 | ▶ | sub _raised_arguments { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_raised_arguments: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 142 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 142 | ▶ | @_ and $self->{_raised_arguments} = [ @_ ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 142 | $self->{_raised_arguments}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 275 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||