line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Error::Tiny::Exception; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Carp; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1505
|
use overload '""' => \&to_string, fallback => 1; |
|
1
|
|
|
|
|
1023
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
14
|
|
|
14
|
0
|
29
|
my $class = shift; |
12
|
14
|
|
|
|
|
80
|
my (%params) = @_; |
13
|
|
|
|
|
|
|
|
14
|
14
|
|
|
|
|
67
|
my $self = {}; |
15
|
14
|
|
|
|
|
36
|
bless $self, $class; |
16
|
|
|
|
|
|
|
|
17
|
14
|
|
|
|
|
160
|
$self->{message} = $params{message}; |
18
|
14
|
|
|
|
|
33
|
$self->{file} = $params{file}; |
19
|
14
|
|
|
|
|
37
|
$self->{line} = $params{line}; |
20
|
|
|
|
|
|
|
|
21
|
14
|
|
|
|
|
50
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
5
|
|
|
5
|
1
|
60
|
sub message { $_[0]->{message} } |
25
|
4
|
|
|
4
|
1
|
25
|
sub line { $_[0]->{line} } |
26
|
4
|
|
|
4
|
1
|
24
|
sub file { $_[0]->{file} } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub throw { |
29
|
5
|
|
|
5
|
1
|
37
|
my $class = shift; |
30
|
5
|
|
|
|
|
9
|
my ($message) = @_; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
32
|
my (undef, $file, $line) = caller(0); |
33
|
5
|
|
|
|
|
28
|
my $self = $class->new(message => $message, file => $file, line => $line); |
34
|
|
|
|
|
|
|
|
35
|
5
|
|
|
|
|
173
|
Carp::croak($self); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub rethrow { |
39
|
1
|
|
|
1
|
1
|
13
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
27
|
Carp::croak($self); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub catch { |
45
|
4
|
|
|
4
|
0
|
11
|
my $self = shift; |
46
|
4
|
|
|
|
|
10
|
my ($then, @tail) = @_; |
47
|
|
|
|
|
|
|
|
48
|
4
|
50
|
|
|
|
14
|
my $class = ref($self) ? ref($self) : $self; |
49
|
4
|
|
|
|
|
18
|
(Error::Tiny::Catch->new(handler => $then->handler, class => $class), |
50
|
|
|
|
|
|
|
@tail); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub to_string { |
54
|
5
|
|
|
5
|
0
|
414
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
5
|
|
|
|
|
12
|
my $message = $self->{message}; |
57
|
5
|
|
|
|
|
52
|
$message =~ s{$}{ at $self->{file} line $self->{line}.}m; |
58
|
|
|
|
|
|
|
|
59
|
5
|
|
|
|
|
31
|
$message; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |