line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Error; sub Error () {__PACKAGE__} |
2
|
20
|
|
|
20
|
|
134
|
use strict; |
|
20
|
|
|
|
|
38
|
|
|
20
|
|
|
|
|
619
|
|
3
|
20
|
|
|
20
|
|
96
|
use warnings qw(FATAL all NONFATAL misc); |
|
20
|
|
|
|
|
41
|
|
|
20
|
|
|
|
|
751
|
|
4
|
20
|
|
|
20
|
|
151
|
use parent qw(YATT::Lite::Object); |
|
20
|
|
|
|
|
42
|
|
|
20
|
|
|
|
|
118
|
|
5
|
20
|
|
|
20
|
|
1296
|
use constant DEBUG_VERBOSE => $ENV{YATT_DEBUG_VERBOSE}; |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
1301
|
|
6
|
|
|
|
|
|
|
|
7
|
20
|
|
|
20
|
|
146
|
use Exporter qw/import/; |
|
20
|
|
|
|
|
45
|
|
|
20
|
|
|
|
|
1358
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/Error/; |
9
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
10
|
|
|
|
|
|
|
|
11
|
20
|
|
|
|
|
139
|
use YATT::Lite::MFields qw/cf_file cf_line cf_tmpl_file cf_tmpl_line |
12
|
|
|
|
|
|
|
cf_http_status_code |
13
|
|
|
|
|
|
|
cf_backtrace |
14
|
20
|
|
|
20
|
|
125
|
cf_reason cf_format cf_args/; |
|
20
|
|
|
|
|
39
|
|
15
|
20
|
|
|
|
|
200
|
use overload qw("" message |
16
|
|
|
|
|
|
|
eq streq |
17
|
|
|
|
|
|
|
bool has_error |
18
|
20
|
|
|
20
|
|
176
|
); |
|
20
|
|
|
|
|
43
|
|
19
|
20
|
|
|
20
|
|
2131
|
use YATT::Lite::Util qw(lexpand untaint_any); |
|
20
|
|
|
|
|
49
|
|
|
20
|
|
|
|
|
973
|
|
20
|
20
|
|
|
20
|
|
121
|
use Carp; |
|
20
|
|
|
|
|
59
|
|
|
20
|
|
|
|
|
4832
|
|
21
|
|
|
|
|
|
|
require Scalar::Util; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub has_error { |
24
|
1
|
|
|
1
|
0
|
7
|
defined $_[0]; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub streq { |
28
|
1
|
|
|
1
|
0
|
101
|
my ($obj, $other, $inv) = @_; |
29
|
1
|
50
|
|
|
|
3
|
($obj, $other) = ($other, $obj) if $inv; |
30
|
1
|
|
|
|
|
4
|
$obj->message eq $other; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub message { |
34
|
30
|
|
|
30
|
0
|
5655
|
my Error $error = shift; |
35
|
30
|
|
|
|
|
121
|
my $msg = $error->reason . $error->place; |
36
|
30
|
|
|
|
|
57
|
$msg .= $error->{cf_backtrace} // '' if DEBUG_VERBOSE; |
37
|
30
|
|
|
|
|
174
|
$msg; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub reason { |
41
|
47
|
|
|
47
|
0
|
504
|
my Error $error = shift; |
42
|
47
|
100
|
|
|
|
197
|
if ($error->{cf_reason}) { |
|
|
100
|
|
|
|
|
|
43
|
10
|
|
|
|
|
92
|
$error->{cf_reason}; |
44
|
|
|
|
|
|
|
} elsif ($error->{cf_format}) { |
45
|
34
|
50
|
|
|
|
197
|
if (Scalar::Util::tainted($error->{cf_format})) { |
46
|
|
|
|
|
|
|
croak "Format is tainted in error reason(" |
47
|
|
|
|
|
|
|
.join(" ", map { |
48
|
0
|
0
|
|
|
|
0
|
if (defined $_) { |
49
|
0
|
|
|
|
|
0
|
untaint_any($_) |
50
|
|
|
|
|
|
|
} else { |
51
|
0
|
|
|
|
|
0
|
'(undef)' |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
0
|
} $error->{cf_format}, lexpand($error->{cf_args})).")"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
BEGIN { |
56
|
20
|
50
|
|
20
|
|
3819
|
warnings->unimport(qw/redundant/) if $] >= 5.021002; # for sprintf |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sprintf $error->{cf_format}, map { |
59
|
47
|
50
|
|
|
|
476
|
defined $_ ? $_ : '(undef)' |
60
|
34
|
|
|
|
|
151
|
} lexpand($error->{cf_args}); |
61
|
|
|
|
|
|
|
} else { |
62
|
3
|
|
|
|
|
58
|
"Unknown reason!" |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub place { |
67
|
30
|
|
|
30
|
0
|
80
|
(my Error $err) = @_; |
68
|
30
|
|
|
|
|
69
|
my $place = ''; |
69
|
30
|
100
|
|
|
|
123
|
$place .= " at file $err->{cf_tmpl_file}" if $err->{cf_tmpl_file}; |
70
|
30
|
100
|
|
|
|
110
|
$place .= " line $err->{cf_tmpl_line}" if $err->{cf_tmpl_line}; |
71
|
30
|
100
|
|
|
|
88
|
if ($err->{cf_file}) { |
72
|
28
|
|
|
|
|
113
|
$place .= ",\n reported from YATT Engine: $err->{cf_file} line $err->{cf_line}"; |
73
|
|
|
|
|
|
|
} |
74
|
30
|
100
|
|
|
|
105
|
$place .= "\n" if $place ne ""; # To make 'warn/die' happy. |
75
|
30
|
|
|
|
|
80
|
$place; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |