line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Error::Pure::HTTP::JSON; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
3
|
|
|
3
|
|
35742
|
use base qw(Exporter); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
365
|
|
5
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
101
|
|
6
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
106
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Modules. |
9
|
3
|
|
|
3
|
|
3131
|
use Error::Pure::Output::JSON qw(err_json); |
|
3
|
|
|
|
|
54244
|
|
|
3
|
|
|
|
|
84
|
|
10
|
3
|
|
|
3
|
|
37055
|
use Error::Pure::Utils qw(err_helper); |
|
3
|
|
|
|
|
6748
|
|
|
3
|
|
|
|
|
73
|
|
11
|
3
|
|
|
3
|
|
3422
|
use List::MoreUtils qw(none); |
|
3
|
|
|
|
|
4442
|
|
|
3
|
|
|
|
|
278
|
|
12
|
3
|
|
|
3
|
|
25
|
use Readonly; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1038
|
|
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
|
|
|
|
|
|
|
# Ignore die signal. |
22
|
|
|
|
|
|
|
$SIG{__DIE__} = 'IGNORE'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Process error. |
25
|
|
|
|
|
|
|
sub err { |
26
|
0
|
|
|
0
|
1
|
|
my @msg = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Get errors structure. |
29
|
0
|
|
|
|
|
|
my @errors = err_helper(@msg); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Finalize in main on last err. |
32
|
0
|
|
|
|
|
|
my $stack_ar = $errors[-1]->{'stack'}; |
33
|
0
|
0
|
0
|
|
|
|
if ($stack_ar->[-1]->{'class'} eq 'main' |
34
|
0
|
0
|
|
0
|
|
|
&& none { $_ eq $EVAL || $_ =~ /^eval '/ms } |
35
|
0
|
|
|
|
|
|
map { $_->{'sub'} } @{$stack_ar}) { |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
print "Content-type: application/json\n\n"; |
38
|
0
|
|
|
|
|
|
print err_json(\@errors); |
39
|
0
|
|
|
|
|
|
return; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Die for eval. |
42
|
|
|
|
|
|
|
} else { |
43
|
0
|
|
|
|
|
|
my $e = $errors[-1]->{'msg'}->[0]; |
44
|
0
|
|
|
|
|
|
chomp $e; |
45
|
0
|
|
|
|
|
|
die "$e\n"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |