| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Error::Pure::HTTP::Error; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 3 |  |  | 3 |  | 60540 | use base qw(Exporter); | 
|  | 3 |  |  |  |  | 22 |  | 
|  | 3 |  |  |  |  | 362 |  | 
| 4 | 3 |  |  | 3 |  | 17 | use strict; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 59 |  | 
| 5 | 3 |  |  | 3 |  | 12 | use warnings; | 
|  | 3 |  |  |  |  | 4 |  | 
|  | 3 |  |  |  |  | 78 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 3 |  |  | 3 |  | 1254 | use Error::Pure::Utils qw(err_helper); | 
|  | 3 |  |  |  |  | 15793 |  | 
|  | 3 |  |  |  |  | 98 |  | 
| 8 | 3 |  |  | 3 |  | 1587 | use Error::Pure::Output::Text qw(err_line); | 
|  | 3 |  |  |  |  | 3558 |  | 
|  | 3 |  |  |  |  | 48 |  | 
| 9 | 3 |  |  | 3 |  | 1637 | use List::MoreUtils qw(none); | 
|  | 3 |  |  |  |  | 39239 |  | 
|  | 3 |  |  |  |  | 15 |  | 
| 10 | 3 |  |  | 3 |  | 2487 | use Readonly; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 827 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | # Constants. | 
| 13 |  |  |  |  |  |  | Readonly::Array our @EXPORT_OK => qw(err); | 
| 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 | 1903 | my @msg = @_; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | # Get errors structure. | 
| 27 | 5 |  |  |  |  | 17 | my @errors = err_helper(@msg); | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | # Finalize in main on last err. | 
| 30 | 5 |  |  |  |  | 1037 | my $stack_ar = $errors[-1]->{'stack'}; | 
| 31 | 5 | 50 | 33 |  |  | 31 | if ($stack_ar->[-1]->{'class'} eq 'main' | 
| 32 | 10 | 100 |  | 10 |  | 42 | && none { $_ eq $EVAL || $_ =~ m/^eval '/ms } | 
| 33 | 10 |  |  |  |  | 36 | map { $_->{'sub'} } @{$stack_ar}) { | 
|  | 5 |  |  |  |  | 11 |  | 
| 34 |  |  |  |  |  |  |  | 
| 35 | 0 |  |  |  |  | 0 | print "Content-type: text/plain\n\n"; | 
| 36 | 0 |  |  |  |  | 0 | print err_line(@errors); | 
| 37 | 0 |  |  |  |  | 0 | return; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | # Die for eval. | 
| 40 |  |  |  |  |  |  | } else { | 
| 41 | 5 |  |  |  |  | 12 | my $e = $errors[-1]->{'msg'}->[0]; | 
| 42 | 5 | 50 |  |  |  | 21 | if (! defined $e) { | 
| 43 | 0 |  |  |  |  | 0 | $e = 'undef'; | 
| 44 |  |  |  |  |  |  | } else { | 
| 45 | 5 |  |  |  |  | 7 | chomp $e; | 
| 46 |  |  |  |  |  |  | } | 
| 47 | 5 |  |  |  |  | 29 | die "$e\n"; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | 1; | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | __END__ |