line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Exception; |
2
|
7
|
|
|
7
|
|
27
|
use strict; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
201
|
|
3
|
7
|
|
|
7
|
|
23
|
use warnings FATAL => qw(all); |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
231
|
|
4
|
7
|
|
|
7
|
|
24
|
use base qw(YATT::Class::Configurable); |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
523
|
|
5
|
7
|
|
|
7
|
|
28
|
BEGIN {require Exporter; *import = \&Exporter::import} |
|
7
|
|
|
|
|
113
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
23
|
use overload '""' => 'string'; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
51
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub Exception () {__PACKAGE__} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(Exception is_normal_end can_retry); |
12
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
13
|
|
|
|
|
|
|
|
14
|
7
|
|
|
7
|
|
1570
|
use YATT::LRXML::Node qw(stringify_node); |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
546
|
|
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
|
|
38
|
use YATT::Fields qw(cf_normal cf_error |
17
|
|
|
|
|
|
|
cf_caller |
18
|
|
|
|
|
|
|
cf_other |
19
|
|
|
|
|
|
|
cf_retry |
20
|
|
|
|
|
|
|
cf_node_obj cf_node cf_file cf_line |
21
|
|
|
|
|
|
|
cf_error_title |
22
|
|
|
|
|
|
|
cf_error_fmt |
23
|
|
|
|
|
|
|
cf_error_param |
24
|
|
|
|
|
|
|
cf_original_error |
25
|
7
|
|
|
7
|
|
29
|
); |
|
7
|
|
|
|
|
9
|
|
26
|
|
|
|
|
|
|
# cf_phase cf_target |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub title { |
29
|
0
|
|
|
0
|
0
|
0
|
(my MY $err) = @_; |
30
|
0
|
0
|
|
|
|
0
|
$err->{cf_error_title} || do { |
31
|
0
|
|
|
|
|
0
|
my $msg = $err->simple; |
32
|
0
|
0
|
|
|
|
0
|
$msg =~ s/[\(:\n].*// if defined $msg; |
33
|
0
|
|
|
|
|
0
|
$msg; |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub simple { |
38
|
55
|
|
|
55
|
0
|
54
|
(my MY $err) = @_; |
39
|
55
|
50
|
|
|
|
120
|
$err->{cf_error} || do { |
40
|
55
|
|
|
|
|
66
|
my $msg = ''; |
41
|
42
|
50
|
|
|
|
146
|
$msg .= sprintf($err->{cf_error_fmt} |
42
|
55
|
50
|
|
|
|
167
|
, map {defined $_ ? $_ : "(null)"} |
43
|
55
|
50
|
|
|
|
164
|
map {$_ ? @$_ : ()} $err->{cf_error_param}) |
44
|
|
|
|
|
|
|
if $err->{cf_error_fmt}; |
45
|
55
|
|
|
|
|
168
|
$msg |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub string { |
50
|
55
|
|
|
55
|
0
|
221
|
(my MY $err) = @_; |
51
|
55
|
50
|
|
|
|
173
|
$err->{cf_error} || do { |
52
|
55
|
|
|
|
|
92
|
$err->simple . " " . $err->error_place . "\n"; |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub error_node { |
57
|
0
|
|
|
0
|
0
|
0
|
(my MY $err) = @_; |
58
|
0
|
0
|
|
|
|
0
|
$err->{cf_node} || do { |
59
|
0
|
0
|
|
|
|
0
|
$err->{cf_node_obj} ? stringify_node($err->{cf_node_obj}) : "" |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub error_place { |
64
|
55
|
|
|
55
|
0
|
56
|
(my MY $err) = @_; |
65
|
55
|
|
|
|
|
62
|
my $place = ''; |
66
|
55
|
100
|
|
|
|
156
|
$place .= "($err->{cf_node}), " if $err->{cf_node}; |
67
|
55
|
50
|
|
|
|
140
|
$place .= "at file $err->{cf_file}" if $err->{cf_file}; |
68
|
55
|
50
|
|
|
|
141
|
$place .= " line $err->{cf_line}" if $err->{cf_line}; |
69
|
55
|
|
|
|
|
412
|
$place; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub is_normal_end { |
73
|
0
|
|
|
0
|
0
|
|
(my MY $err) = @_; |
74
|
0
|
0
|
0
|
|
|
|
ref $err |
|
|
|
0
|
|
|
|
|
75
|
|
|
|
|
|
|
and UNIVERSAL::isa($err, MY) |
76
|
|
|
|
|
|
|
and not $err->{cf_error} |
77
|
|
|
|
|
|
|
and $err->{cf_normal}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub can_retry { |
81
|
0
|
|
|
0
|
0
|
|
(my MY $err) = @_; |
82
|
|
|
|
|
|
|
return unless |
83
|
0
|
0
|
0
|
|
|
|
ref $err |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
84
|
|
|
|
|
|
|
and UNIVERSAL::isa($err, MY) |
85
|
|
|
|
|
|
|
and not $err->{cf_error} |
86
|
|
|
|
|
|
|
and $err->{cf_retry} |
87
|
|
|
|
|
|
|
and ref $err->{cf_retry} eq 'ARRAY'; |
88
|
0
|
0
|
|
|
|
|
wantarray ? @{$err->{cf_retry}} : $err->{cf_retry}; |
|
0
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |