line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Error::Pure::JSON; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
107185
|
use base qw(Exporter); |
|
3
|
|
|
|
|
30
|
|
|
3
|
|
|
|
|
460
|
|
4
|
3
|
|
|
3
|
|
21
|
use strict; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
63
|
|
5
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
113
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1423
|
use Error::Pure::Output::JSON qw(err_json); |
|
3
|
|
|
|
|
50741
|
|
|
3
|
|
|
|
|
73
|
|
8
|
3
|
|
|
3
|
|
1609
|
use Error::Pure::Utils qw(err_helper); |
|
3
|
|
|
|
|
6163
|
|
|
3
|
|
|
|
|
74
|
|
9
|
3
|
|
|
3
|
|
1937
|
use List::MoreUtils qw(none); |
|
3
|
|
|
|
|
40421
|
|
|
3
|
|
|
|
|
21
|
|
10
|
3
|
|
|
3
|
|
3169
|
use Readonly; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1062
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Constants. |
13
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(err); |
14
|
|
|
|
|
|
|
Readonly::Scalar my $EVAL => 'eval {...}'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = 0.08; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Ignore die signal. |
19
|
|
|
|
|
|
|
$SIG{__DIE__} = 'IGNORE'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Process error. |
22
|
|
|
|
|
|
|
sub err { |
23
|
5
|
|
|
5
|
1
|
2579
|
my @msg = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Get errors structure. |
26
|
5
|
|
|
|
|
19
|
my @errors = err_helper(@msg); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Finalize in main on last err. |
29
|
5
|
|
|
|
|
985
|
my $stack_ar = $errors[-1]->{'stack'}; |
30
|
5
|
50
|
33
|
|
|
32
|
if ($stack_ar->[-1]->{'class'} eq 'main' |
31
|
10
|
100
|
|
10
|
|
41
|
&& none { $_ eq $EVAL || $_ =~ /^eval '/ms } |
32
|
10
|
|
|
|
|
32
|
map { $_->{'sub'} } @{$stack_ar}) { |
|
5
|
|
|
|
|
12
|
|
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
die err_json(\@errors)."\n"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Die for eval. |
37
|
|
|
|
|
|
|
} else { |
38
|
5
|
|
|
|
|
9
|
my $e = $errors[-1]->{'msg'}->[0]; |
39
|
5
|
50
|
|
|
|
12
|
if (! defined $e) { |
40
|
0
|
|
|
|
|
0
|
$e = 'undef'; |
41
|
|
|
|
|
|
|
} else { |
42
|
5
|
|
|
|
|
10
|
chomp $e; |
43
|
|
|
|
|
|
|
} |
44
|
5
|
|
|
|
|
30
|
die "$e\n"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |