line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Error::Pure::HTTP::Print; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
61375
|
use base qw(Exporter); |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
370
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
55
|
|
5
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
79
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1171
|
use Error::Pure::Utils qw(err_helper); |
|
3
|
|
|
|
|
14481
|
|
|
3
|
|
|
|
|
56
|
|
8
|
3
|
|
|
3
|
|
1625
|
use List::MoreUtils qw(none); |
|
3
|
|
|
|
|
31474
|
|
|
3
|
|
|
|
|
16
|
|
9
|
3
|
|
|
3
|
|
2459
|
use Readonly; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
989
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Constants. |
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(err); |
13
|
|
|
|
|
|
|
Readonly::Scalar my $EMPTY_STR => q{}; |
14
|
|
|
|
|
|
|
Readonly::Scalar my $EVAL => 'eval {...}'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Version. |
17
|
|
|
|
|
|
|
our $VERSION = 0.15; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Ignore die signal. |
20
|
|
|
|
|
|
|
$SIG{__DIE__} = 'IGNORE'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Process error. |
23
|
|
|
|
|
|
|
sub err { |
24
|
5
|
|
|
5
|
1
|
1523
|
my @msg = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Get errors structure. |
27
|
5
|
|
|
|
|
14
|
my @errors = err_helper(@msg); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Error message. |
30
|
5
|
|
|
|
|
839
|
my $e = $errors[-1]->{'msg'}->[0]; |
31
|
5
|
50
|
|
|
|
11
|
if (! defined $e) { |
32
|
0
|
|
|
|
|
0
|
$e = 'undef'; |
33
|
|
|
|
|
|
|
} else { |
34
|
5
|
|
|
|
|
7
|
chomp $e; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Finalize in main on last err. |
38
|
5
|
|
|
|
|
8
|
my $stack_ar = $errors[-1]->{'stack'}; |
39
|
5
|
50
|
33
|
|
|
22
|
if ($stack_ar->[-1]->{'class'} eq 'main' |
40
|
10
|
100
|
|
10
|
|
32
|
&& none { $_ eq $EVAL || $_ =~ /^eval '/ms } |
41
|
10
|
|
|
|
|
24
|
map { $_->{'sub'} } @{$stack_ar}) { |
|
5
|
|
|
|
|
10
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
my $class = $errors[-1]->{'stack'}->[0]->{'class'}; |
44
|
0
|
0
|
|
|
|
0
|
if ($class eq 'main') { |
45
|
0
|
|
|
|
|
0
|
$class = $EMPTY_STR |
46
|
|
|
|
|
|
|
} |
47
|
0
|
0
|
|
|
|
0
|
if ($class) { |
48
|
0
|
|
|
|
|
0
|
$class .= ': '; |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
0
|
print "Content-type: text/plain\n\n"; |
51
|
0
|
|
|
|
|
0
|
print $class."$e\n"; |
52
|
0
|
|
|
|
|
0
|
return; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Die for eval. |
55
|
|
|
|
|
|
|
} else { |
56
|
5
|
|
|
|
|
21
|
die "$e\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |