File Coverage

blib/lib/Aion/Carp.pm
Criterion Covered Total %
statement 29 29 100.0
branch 6 6 100.0
condition 3 3 100.0
subroutine 8 8 100.0
pod 1 1 100.0
total 47 47 100.0


line stmt bran cond sub pod time code
1             package Aion::Carp;
2 1     1   241683 use 5.008001;
  1         3  
3 1     1   4 use common::sense;
  1         1  
  1         6  
4              
5             our $VERSION = "1.6";
6              
7 1     1   71 use Carp qw//;
  1         29  
  1         31  
8 1     1   4 use Scalar::Util qw//;
  1         1  
  1         66  
9              
10             sub handler {
11 7     7 1 213007 my ($x) = @_;
12              
13 7 100 100     41 if(!ref $x) {
    100          
14 1     1   467 no utf8; use bytes;
  1     1   210  
  1         6  
  1         24  
  1         2  
  1         6  
15 4 100       24 if($x =~ s/\n[ \t]+\.\.\.propagated at .* line \d+\.\n\z/\n/) {}
16             else {
17 3         27 $x =~ s/ at .*? line \d+\.\n\z//;
18 3         1199 my $c = Carp::longmess('');
19 3         46 $c =~ s/^( at .*? line \d+)\.\n/$x\n\tdie(...) called$1\n/;
20 3         11 $x = $c;
21             }
22             }
23             elsif(Scalar::Util::reftype($x) eq "HASH" && !exists $x->{STACKTRACE}) {
24 1         280 my $c = Carp::longmess("die(...) called");
25 1         15 $c =~ s/^(.*\d+)\.\n/$1\n/;
26 1         4 $x->{STACKTRACE} = $c;
27             }
28              
29 7         65 die $x;
30             }
31              
32             sub import {
33 2     2   7998 $SIG{__DIE__} = \&handler;
34             }
35              
36             1;
37              
38             __END__