line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Error::Pure::HTTP::JSON::Advance; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
3
|
|
|
3
|
|
29687
|
use base qw(Exporter); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
297
|
|
5
|
3
|
|
|
3
|
|
14
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
56
|
|
6
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
82
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Modules. |
9
|
3
|
|
|
3
|
|
312420
|
use Error::Pure::Output::JSON qw(err_json); |
|
3
|
|
|
|
|
62451
|
|
|
3
|
|
|
|
|
72
|
|
10
|
3
|
|
|
3
|
|
2461
|
use Error::Pure::Utils qw(err_helper); |
|
3
|
|
|
|
|
4166
|
|
|
3
|
|
|
|
|
50
|
|
11
|
3
|
|
|
3
|
|
2557
|
use List::MoreUtils qw(none); |
|
3
|
|
|
|
|
34271
|
|
|
3
|
|
|
|
|
21
|
|
12
|
3
|
|
|
3
|
|
1785
|
use Readonly; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1033
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constants. |
15
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(err); |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EVAL => 'eval {...}'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Version. |
19
|
|
|
|
|
|
|
our $VERSION = 0.05; |
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
|
5
|
|
|
5
|
1
|
2070
|
my @msg = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Get errors structure. |
32
|
5
|
|
|
|
|
18
|
my @errors = err_helper(@msg); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Finalize in main on last err. |
35
|
5
|
|
|
|
|
1009
|
my $stack_ar = $errors[-1]->{'stack'}; |
36
|
5
|
50
|
33
|
|
|
26
|
if ($stack_ar->[-1]->{'class'} eq 'main' |
37
|
10
|
100
|
|
10
|
|
44
|
&& none { $_ eq $EVAL || $_ =~ /^eval '/ms } |
38
|
10
|
|
|
|
|
37
|
map { $_->{'sub'} } @{$stack_ar}) { |
|
5
|
|
|
|
|
10
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Construct error structure. |
41
|
0
|
|
|
|
|
0
|
my $err_hr = { |
42
|
|
|
|
|
|
|
'error-pure' => \@errors, |
43
|
|
|
|
|
|
|
}; |
44
|
0
|
|
|
|
|
0
|
foreach my $key (keys %ERR_PARAMETERS) { |
45
|
0
|
|
|
|
|
0
|
$err_hr->{$key} = $ERR_PARAMETERS{$key}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Print out. |
49
|
0
|
|
|
|
|
0
|
print "Content-type: application/json\n\n"; |
50
|
0
|
|
|
|
|
0
|
print err_json($err_hr); |
51
|
0
|
|
|
|
|
0
|
return; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Die for eval. |
54
|
|
|
|
|
|
|
} else { |
55
|
5
|
|
|
|
|
10
|
my $e = $errors[-1]->{'msg'}->[0]; |
56
|
5
|
50
|
|
|
|
8
|
if (! defined $e) { |
57
|
0
|
|
|
|
|
0
|
$e = 'undef'; |
58
|
|
|
|
|
|
|
} else { |
59
|
5
|
|
|
|
|
7
|
chomp $e; |
60
|
|
|
|
|
|
|
} |
61
|
5
|
|
|
|
|
24
|
die "$e\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |