line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Error; sub Error () {__PACKAGE__} |
2
|
14
|
|
|
14
|
|
73
|
use strict; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
411
|
|
3
|
14
|
|
|
14
|
|
140
|
use warnings qw(FATAL all NONFATAL misc); |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
610
|
|
4
|
14
|
|
|
14
|
|
138
|
use parent qw(YATT::Lite::Object); |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
75
|
|
5
|
14
|
|
|
14
|
|
889
|
use constant DEBUG_VERBOSE => $ENV{YATT_DEBUG_VERBOSE}; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
1027
|
|
6
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
80
|
use Exporter qw/import/; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
1090
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/Error/; |
9
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
10
|
|
|
|
|
|
|
|
11
|
14
|
|
|
|
|
99
|
use YATT::Lite::MFields qw/cf_file cf_line cf_tmpl_file cf_tmpl_line |
12
|
|
|
|
|
|
|
cf_http_status_code |
13
|
|
|
|
|
|
|
cf_backtrace |
14
|
14
|
|
|
14
|
|
71
|
cf_reason cf_format cf_args/; |
|
14
|
|
|
|
|
29
|
|
15
|
14
|
|
|
|
|
123
|
use overload qw("" message |
16
|
|
|
|
|
|
|
eq streq |
17
|
|
|
|
|
|
|
bool has_error |
18
|
14
|
|
|
14
|
|
82
|
); |
|
14
|
|
|
|
|
24
|
|
19
|
14
|
|
|
14
|
|
1281
|
use YATT::Lite::Util qw(lexpand untaint_any); |
|
14
|
|
|
|
|
94
|
|
|
14
|
|
|
|
|
771
|
|
20
|
14
|
|
|
14
|
|
70
|
use Carp; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
4374
|
|
21
|
|
|
|
|
|
|
require Scalar::Util; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub has_error { |
24
|
0
|
|
|
0
|
0
|
0
|
defined $_[0]; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub streq { |
28
|
1
|
|
|
1
|
0
|
91
|
my ($obj, $other, $inv) = @_; |
29
|
1
|
50
|
|
|
|
4
|
($obj, $other) = ($other, $obj) if $inv; |
30
|
1
|
|
|
|
|
3
|
$obj->message eq $other; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub message { |
34
|
29
|
|
|
29
|
0
|
4498
|
my Error $error = shift; |
35
|
29
|
|
|
|
|
86
|
my $msg = $error->reason . $error->place; |
36
|
29
|
|
|
|
|
60
|
$msg .= $error->{cf_backtrace} // '' if DEBUG_VERBOSE; |
37
|
29
|
|
|
|
|
144
|
$msg; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub reason { |
41
|
33
|
|
|
33
|
0
|
450
|
my Error $error = shift; |
42
|
33
|
100
|
|
|
|
141
|
if ($error->{cf_reason}) { |
|
|
50
|
|
|
|
|
|
43
|
2
|
|
|
|
|
9
|
$error->{cf_reason}; |
44
|
|
|
|
|
|
|
} elsif ($error->{cf_format}) { |
45
|
31
|
50
|
|
|
|
147
|
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
|
14
|
50
|
|
14
|
|
3476
|
warnings->unimport(qw/redundant/) if $] >= 5.021002; # for sprintf |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sprintf $error->{cf_format}, map { |
59
|
42
|
50
|
|
|
|
260
|
defined $_ ? $_ : '(undef)' |
60
|
31
|
|
|
|
|
130
|
} lexpand($error->{cf_args}); |
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
0
|
"Unknown reason!" |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub place { |
67
|
29
|
|
|
29
|
0
|
54
|
(my Error $err) = @_; |
68
|
29
|
|
|
|
|
42
|
my $place = ''; |
69
|
29
|
100
|
|
|
|
110
|
$place .= " at file $err->{cf_tmpl_file}" if $err->{cf_tmpl_file}; |
70
|
29
|
100
|
|
|
|
110
|
$place .= " line $err->{cf_tmpl_line}" if $err->{cf_tmpl_line}; |
71
|
29
|
100
|
|
|
|
74
|
if ($err->{cf_file}) { |
72
|
27
|
|
|
|
|
84
|
$place .= ",\n reported from YATT Engine: $err->{cf_file} line $err->{cf_line}"; |
73
|
|
|
|
|
|
|
} |
74
|
29
|
100
|
|
|
|
78
|
$place .= "\n" if $place ne ""; # To make 'warn/die' happy. |
75
|
29
|
|
|
|
|
338
|
$place; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |