line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Error::Pure::HTTP::JSON::Advance; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
3
|
|
|
3
|
|
31839
|
use base qw(Exporter); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
331
|
|
5
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
90
|
|
6
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
109
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Modules. |
9
|
3
|
|
|
3
|
|
3002
|
use Error::Pure::Output::JSON qw(err_json); |
|
3
|
|
|
|
|
65568
|
|
|
3
|
|
|
|
|
87
|
|
10
|
3
|
|
|
3
|
|
3502
|
use Error::Pure::Utils qw(err_helper); |
|
3
|
|
|
|
|
5037
|
|
|
3
|
|
|
|
|
58
|
|
11
|
3
|
|
|
3
|
|
3559
|
use List::MoreUtils qw(none); |
|
3
|
|
|
|
|
3932
|
|
|
3
|
|
|
|
|
268
|
|
12
|
3
|
|
|
3
|
|
20
|
use Readonly; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1183
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constants. |
15
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(err); |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EVAL => 'eval {...}'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Version. |
19
|
|
|
|
|
|
|
our $VERSION = 0.03; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Global variables. |
22
|
|
|
|
|
|
|
our %ERR_PARAMETERS; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Ignore die signal. |
25
|
|
|
|
|
|
|
$SIG{__DIE__} = 'IGNORE'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Process error. |
28
|
|
|
|
|
|
|
sub err { |
29
|
0
|
|
|
0
|
1
|
|
my @msg = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Get errors structure. |
32
|
0
|
|
|
|
|
|
my @errors = err_helper(@msg); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Finalize in main on last err. |
35
|
0
|
|
|
|
|
|
my $stack_ar = $errors[-1]->{'stack'}; |
36
|
0
|
0
|
0
|
|
|
|
if ($stack_ar->[-1]->{'class'} eq 'main' |
37
|
0
|
0
|
|
0
|
|
|
&& none { $_ eq $EVAL || $_ =~ /^eval '/ms } |
38
|
0
|
|
|
|
|
|
map { $_->{'sub'} } @{$stack_ar}) { |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Construct error structure. |
41
|
0
|
|
|
|
|
|
my $err_hr = { |
42
|
|
|
|
|
|
|
'error-pure' => \@errors, |
43
|
|
|
|
|
|
|
}; |
44
|
0
|
|
|
|
|
|
foreach my $key (keys %ERR_PARAMETERS) { |
45
|
0
|
|
|
|
|
|
$err_hr->{$key} = $ERR_PARAMETERS{$key}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Print out. |
49
|
0
|
|
|
|
|
|
print "Content-type: application/json\n\n"; |
50
|
0
|
|
|
|
|
|
print err_json($err_hr); |
51
|
0
|
|
|
|
|
|
return; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Die for eval. |
54
|
|
|
|
|
|
|
} else { |
55
|
0
|
|
|
|
|
|
my $e = $errors[-1]->{'msg'}->[0]; |
56
|
0
|
|
|
|
|
|
chomp $e; |
57
|
0
|
|
|
|
|
|
die "$e\n"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |