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.3514_04'; # TRIAL |
5
|
|
|
|
|
|
|
$Dancer::Exception::Base::VERSION = '1.351404'; |
6
|
206
|
|
|
206
|
|
1579
|
use strict; |
|
206
|
|
|
|
|
464
|
|
|
206
|
|
|
|
|
6338
|
|
7
|
206
|
|
|
206
|
|
2048
|
use warnings; |
|
206
|
|
|
|
|
1564
|
|
|
206
|
|
|
|
|
6677
|
|
8
|
206
|
|
|
206
|
|
865
|
use Carp; |
|
206
|
|
|
|
|
387
|
|
|
206
|
|
|
|
|
10844
|
|
9
|
|
|
|
|
|
|
|
10
|
206
|
|
|
206
|
|
1168
|
use base qw(Exporter); |
|
206
|
|
|
|
|
461
|
|
|
206
|
|
|
|
|
26845
|
|
11
|
|
|
|
|
|
|
|
12
|
206
|
|
|
206
|
|
1264
|
use Dancer::Exception; |
|
206
|
|
|
|
|
409
|
|
|
206
|
|
|
|
|
15914
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use overload '""' => sub { |
15
|
58
|
|
|
58
|
|
9761
|
my ($self) = @_; |
16
|
|
|
|
|
|
|
$self->message |
17
|
58
|
100
|
|
|
|
250
|
. ( $Dancer::Exception::Verbose ? $self->{_longmess} : $self->{_shortmess}); |
18
|
206
|
|
|
206
|
|
185809
|
}; |
|
206
|
|
|
|
|
158663
|
|
|
206
|
|
|
|
|
3244
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# string comparison is done without the stack traces |
21
|
|
|
|
|
|
|
use overload 'cmp' => sub { |
22
|
2
|
|
|
2
|
|
378
|
my ($e, $f) = @_; |
23
|
2
|
50
|
33
|
|
|
30
|
( ref $e && $e->isa(__PACKAGE__) |
|
|
50
|
33
|
|
|
|
|
24
|
|
|
|
|
|
|
? $e->message : $e ) |
25
|
|
|
|
|
|
|
cmp |
26
|
|
|
|
|
|
|
( ref $f && $f->isa(__PACKAGE__) |
27
|
|
|
|
|
|
|
? $f->message : $f ) |
28
|
206
|
|
|
206
|
|
21794
|
}; |
|
206
|
|
|
|
|
402
|
|
|
206
|
|
|
|
|
1088
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# This is the base class of all exceptions |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
41
|
|
|
41
|
0
|
115
|
my $class = shift; |
34
|
41
|
|
|
|
|
190
|
my $self = bless { _raised_arguments => [], |
35
|
|
|
|
|
|
|
_shortmess => '', |
36
|
|
|
|
|
|
|
_longmess => '', |
37
|
|
|
|
|
|
|
}, $class; |
38
|
41
|
|
|
|
|
221
|
$self->_raised_arguments(@_); |
39
|
41
|
|
|
|
|
99
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# base class has a passthrough message |
43
|
0
|
|
|
0
|
|
0
|
sub _message_pattern { '%s' } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub throw { |
46
|
41
|
|
|
41
|
1
|
79
|
my $self = shift; |
47
|
41
|
|
|
|
|
120
|
$self->_raised_arguments(@_); |
48
|
41
|
|
|
|
|
104
|
local $Carp::CarpInternal; |
49
|
41
|
|
|
|
|
87
|
local $Carp::Internal; |
50
|
41
|
|
|
|
|
141
|
$Carp::Internal{'Dancer'} ++; |
51
|
41
|
|
|
|
|
81
|
$Carp::CarpInternal{'Dancer::Exception'} ++; |
52
|
41
|
|
|
|
|
6376
|
$self->{_shortmess} = Carp::shortmess; |
53
|
41
|
|
|
|
|
6444
|
$self->{_longmess} = Carp::longmess; |
54
|
41
|
|
|
|
|
6624
|
die $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
0
|
sub rethrow { die $_[0] } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub message { |
60
|
60
|
|
|
60
|
1
|
117
|
my ($self) = @_; |
61
|
60
|
|
|
|
|
296
|
my $message_pattern = $self->_message_pattern; |
62
|
60
|
|
|
|
|
114
|
my $message = sprintf($message_pattern, @{$self->_raised_arguments}); |
|
60
|
|
|
|
|
130
|
|
63
|
60
|
|
|
|
|
488
|
return $message; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub does { |
67
|
5
|
|
|
5
|
1
|
534
|
my $self = shift; |
68
|
5
|
|
|
|
|
11
|
my $regexp = join('|', map { '^' . $_ . '$'; } @_); |
|
5
|
|
|
|
|
19
|
|
69
|
5
|
|
|
|
|
17
|
(scalar grep { /$regexp/ } $self->get_composition) >= 1; |
|
18
|
|
|
|
|
100
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_composition { |
73
|
6
|
|
|
6
|
1
|
18
|
my ($self) = @_; |
74
|
6
|
|
|
|
|
10
|
my $class = ref($self); |
75
|
|
|
|
|
|
|
|
76
|
6
|
|
|
|
|
8
|
my ($_recurse_isa, %seen); |
77
|
|
|
|
|
|
|
$_recurse_isa = sub { |
78
|
34
|
|
|
34
|
|
47
|
my ($class) = @_; |
79
|
34
|
100
|
|
|
|
89
|
$seen{$class}++ |
80
|
|
|
|
|
|
|
and return; |
81
|
|
|
|
|
|
|
|
82
|
206
|
|
|
206
|
|
71096
|
no strict 'refs'; |
|
206
|
|
|
|
|
407
|
|
|
206
|
|
|
|
|
36677
|
|
83
|
28
|
|
|
|
|
49
|
return $class, map { $_recurse_isa->($_) } |
84
|
34
|
|
|
|
|
88
|
grep { /^Dancer::Exception::/ } |
85
|
23
|
|
|
|
|
62
|
@{"${class}::ISA"}; |
|
23
|
|
|
|
|
70
|
|
86
|
|
|
|
|
|
|
|
87
|
6
|
|
|
|
|
52
|
}; |
88
|
6
|
|
|
|
|
14
|
grep { s/^Dancer::Exception::// } $_recurse_isa->($class); |
|
23
|
|
|
|
|
74
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _raised_arguments { |
92
|
142
|
|
|
142
|
|
220
|
my $self = shift; |
93
|
142
|
100
|
|
|
|
1401
|
@_ and $self->{_raised_arguments} = [ @_ ]; |
94
|
142
|
|
|
|
|
400
|
$self->{_raised_arguments}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |