blib/lib/Error/Pure/Output/Bio.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 package Error::Pure::Output::Bio;
2  
3 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=2.6
8  
9 # Constants.
10 Readonly::Array our @EXPORT => qw(err_bio);
11 Readonly::Scalar my $SPACE => q{ };
12  
13 our $VERSION = 0.01;
14  
15 # Bio error print.
16 sub err_bio {
17 my @errors = @_;
18  
19 my @ret;
20 foreach my $error_hr (@errors) {
21 my $e = shift @{$error_hr->{'msg'}};
22 chomp $e;
23  
24 # Title.
25 # XXX Add class.
26 my $title = '------------- EXCEPTION -------------';
27 push @ret, $title;
28  
29 # Error.
30 push @ret, 'MSG: '.$e;
31  
32 # Value.
33 while (@{$error_hr->{'msg'}}) {
34 my $f = shift @{$error_hr->{'msg'}};
35 my $t = shift @{$error_hr->{'msg'}};
36  
37 if (! defined $f) {
38 last;
39 }
40 my $ret = 'VALUE: '.$f;
41 if ($t) {
42 $ret .= ': '.$t;
43 }
44 push @ret, $ret;
45 }
46  
47 # Stack trace.
48 foreach my $i (0 .. $#{$error_hr->{'stack'}}) {
49 my $st = $error_hr->{'stack'}->[$i];
50 my $ret = 'STACK: '.$st->{'class'};
51 $ret .= $SPACE.$st->{'prog'};
52 $ret .= ':'.$st->{'line'};
53 push @ret, $ret;
54 }
55  
56 # Footer.
57 my $footer = ('-' x length($title));
58 push @ret, $footer;
59 }
60  
61 return wantarray ? @ret : (join "\n", @ret)."\n";
62 }
63  
64 1;
65  
66 __END__
↑ Summary