line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Exception::Base; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:SUKRIA'; |
3
|
|
|
|
|
|
|
#ABSTRACT: the base class of all Dancer exceptions |
4
|
|
|
|
|
|
|
$Dancer::Exception::Base::VERSION = '1.3520'; |
5
|
205
|
|
|
205
|
|
1361
|
use strict; |
|
205
|
|
|
|
|
455
|
|
|
205
|
|
|
|
|
7506
|
|
6
|
205
|
|
|
205
|
|
2847
|
use warnings; |
|
205
|
|
|
|
|
449
|
|
|
205
|
|
|
|
|
6630
|
|
7
|
205
|
|
|
205
|
|
2690
|
use Carp; |
|
205
|
|
|
|
|
2318
|
|
|
205
|
|
|
|
|
12853
|
|
8
|
|
|
|
|
|
|
|
9
|
205
|
|
|
205
|
|
1443
|
use base qw(Exporter); |
|
205
|
|
|
|
|
588
|
|
|
205
|
|
|
|
|
34851
|
|
10
|
|
|
|
|
|
|
|
11
|
205
|
|
|
205
|
|
1566
|
use Dancer::Exception; |
|
205
|
|
|
|
|
565
|
|
|
205
|
|
|
|
|
20403
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use overload '""' => sub { |
14
|
58
|
|
|
58
|
|
11200
|
my ($self) = @_; |
15
|
|
|
|
|
|
|
$self->message |
16
|
58
|
100
|
|
|
|
277
|
. ( $Dancer::Exception::Verbose ? $self->{_longmess} : $self->{_shortmess}); |
17
|
205
|
|
|
205
|
|
235869
|
}; |
|
205
|
|
|
|
|
197365
|
|
|
205
|
|
|
|
|
3945
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# string comparison is done without the stack traces |
20
|
|
|
|
|
|
|
use overload 'cmp' => sub { |
21
|
2
|
|
|
2
|
|
460
|
my ($e, $f) = @_; |
22
|
2
|
50
|
33
|
|
|
32
|
( ref $e && $e->isa(__PACKAGE__) |
|
|
50
|
33
|
|
|
|
|
23
|
|
|
|
|
|
|
? $e->message : $e ) |
24
|
|
|
|
|
|
|
cmp |
25
|
|
|
|
|
|
|
( ref $f && $f->isa(__PACKAGE__) |
26
|
|
|
|
|
|
|
? $f->message : $f ) |
27
|
205
|
|
|
205
|
|
26429
|
}; |
|
205
|
|
|
|
|
488
|
|
|
205
|
|
|
|
|
1411
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# This is the base class of all exceptions |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
41
|
|
|
41
|
0
|
114
|
my $class = shift; |
33
|
41
|
|
|
|
|
228
|
my $self = bless { _raised_arguments => [], |
34
|
|
|
|
|
|
|
_shortmess => '', |
35
|
|
|
|
|
|
|
_longmess => '', |
36
|
|
|
|
|
|
|
}, $class; |
37
|
41
|
|
|
|
|
250
|
$self->_raised_arguments(@_); |
38
|
41
|
|
|
|
|
118
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# base class has a passthrough message |
42
|
0
|
|
|
0
|
|
0
|
sub _message_pattern { '%s' } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub throw { |
45
|
41
|
|
|
41
|
1
|
91
|
my $self = shift; |
46
|
41
|
|
|
|
|
176
|
$self->_raised_arguments(@_); |
47
|
41
|
|
|
|
|
95
|
local $Carp::CarpInternal; |
48
|
41
|
|
|
|
|
83
|
local $Carp::Internal; |
49
|
41
|
|
|
|
|
122
|
$Carp::Internal{'Dancer'} ++; |
50
|
41
|
|
|
|
|
99
|
$Carp::CarpInternal{'Dancer::Exception'} ++; |
51
|
41
|
|
|
|
|
7671
|
$self->{_shortmess} = Carp::shortmess; |
52
|
41
|
|
|
|
|
7997
|
$self->{_longmess} = Carp::longmess; |
53
|
41
|
|
|
|
|
7861
|
die $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
0
|
sub rethrow { die $_[0] } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub message { |
59
|
60
|
|
|
60
|
1
|
163
|
my ($self) = @_; |
60
|
60
|
|
|
|
|
319
|
my $message_pattern = $self->_message_pattern; |
61
|
60
|
|
|
|
|
123
|
my $message = sprintf($message_pattern, @{$self->_raised_arguments}); |
|
60
|
|
|
|
|
154
|
|
62
|
60
|
|
|
|
|
689
|
return $message; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub does { |
66
|
5
|
|
|
5
|
1
|
676
|
my $self = shift; |
67
|
5
|
|
|
|
|
18
|
my $regexp = join('|', map { '^' . $_ . '$'; } @_); |
|
5
|
|
|
|
|
21
|
|
68
|
5
|
|
|
|
|
22
|
(scalar grep { /$regexp/ } $self->get_composition) >= 1; |
|
18
|
|
|
|
|
162
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_composition { |
72
|
6
|
|
|
6
|
1
|
25
|
my ($self) = @_; |
73
|
6
|
|
|
|
|
12
|
my $class = ref($self); |
74
|
|
|
|
|
|
|
|
75
|
6
|
|
|
|
|
10
|
my ($_recurse_isa, %seen); |
76
|
|
|
|
|
|
|
$_recurse_isa = sub { |
77
|
34
|
|
|
34
|
|
53
|
my ($class) = @_; |
78
|
34
|
100
|
|
|
|
114
|
$seen{$class}++ |
79
|
|
|
|
|
|
|
and return; |
80
|
|
|
|
|
|
|
|
81
|
205
|
|
|
205
|
|
89446
|
no strict 'refs'; |
|
205
|
|
|
|
|
609
|
|
|
205
|
|
|
|
|
45494
|
|
82
|
28
|
|
|
|
|
68
|
return $class, map { $_recurse_isa->($_) } |
83
|
34
|
|
|
|
|
132
|
grep { /^Dancer::Exception::/ } |
84
|
23
|
|
|
|
|
35
|
@{"${class}::ISA"}; |
|
23
|
|
|
|
|
96
|
|
85
|
|
|
|
|
|
|
|
86
|
6
|
|
|
|
|
29
|
}; |
87
|
6
|
|
|
|
|
16
|
grep { s/^Dancer::Exception::// } $_recurse_isa->($class); |
|
23
|
|
|
|
|
84
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _raised_arguments { |
91
|
142
|
|
|
142
|
|
265
|
my $self = shift; |
92
|
142
|
100
|
|
|
|
1742
|
@_ and $self->{_raised_arguments} = [ @_ ]; |
93
|
142
|
|
|
|
|
517
|
$self->{_raised_arguments}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |