lib/File/Properties/Error.pm

filter: Statementstmt 47.5% 19 / 40 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 71.4% 5 / 7 Podpod 50.0% 1 / 2 totaltotal 35.7% 25 / 70 CC 10 SCAR 39.5
CC
10
Cov
33%
string
90.0
new
6.0
BEGIN
1.0
CRAP 51.7
↑ Summary blib/lib/File/Properties/Media.pm »
1 # ----------------------------------------------------------------------------
2 #
3 # This is an exception handling module for File::Properties.
4 #
5 # Copyright © 2010,2011 Brendt Wohlberg <wohl@cpan.org>
6 # See distribution LICENSE file for license details.
7 #
8 # Most recent modification: 5 November 2011
9 #
10 # ----------------------------------------------------------------------------
11  
12 package File::Properties::Error;
13 6 our $VERSION = 0.01;
14  
15 6 require 5.005;
16 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶use Error qw(:try);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 6 ▶use base qw(Error);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 6 ▶use overload ('""' => 'string');
Subroutine BEGIN: called CC=1 SCAR=0.0
22 6 $File::Properties::Error::Debug = 0;
23  
24  
25 # ----------------------------------------------------------------------------
26 # Constructor
27 # ----------------------------------------------------------------------------
28 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
29 0 my $self = shift;
30 0 my $text = "" . shift;
31 0 my $obrf = shift;
32  
33 0 local $Error::Depth = $Error::Depth + 1;
34 0 ▶ local $Error::Debug = 1 if ($File::Properties::Error::Debug > 1);
Branch: 1 branch
BranchTrueFalseTotal
if $File::Properties::Error::Debug > 1 0 0 0
35  
36 0 $self->SUPER::new('-text' => $text, '-object' => $obrf);
37 }
38  
39  
40 # ----------------------------------------------------------------------------
41 # Construct string from object
42 # ----------------------------------------------------------------------------
43 0 ▶sub string {
Subroutine string: not called CC=9 SCAR=45.0
Pod undocumented
44 0 my $self = shift;
45  
46 0 my $txt;
47 0 ▶ if ($File::Properties::Error::Debug == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($File::Properties::Error::Debug == 0) { } 0 0 0
48 0 $txt = $self->text . "\n";
49 } else {
50 0 ▶ $txt = $self->stacktrace if ($File::Properties::Error::Debug);
Branch: 1 branch
BranchTrueFalseTotal
if $File::Properties::Error::Debug 0 0 0
51 }
52  
53 0 ▶ if ($File::Properties::Error::Debug > 2 and defined($self->object)
Branch: 1 branch
BranchTrueFalseTotal
if ($File::Properties::Error::Debug > 2 and defined $self->object and ref($self->object) =~ /^File::/) 0 0 0
Condition0%0/6
$File::Properties::Error::Debug > 2 and defined $self->object and ref($self->object) =~ /^File::/
!ll&&!rl&&r
000
$File::Properties::Error::Debug > 2 and defined $self->object
!ll&&!rl&&r
000
MC/DC0%0/3
$File::Properties::Error::Debug > 2 and defined $self->object and ref($self->object) =~ /^File::/
$File::Properties::Error::Debug > 2 defined $self->object ref($self->object) =~ /^File::/
Truth table0%0/4
A and B and C
A= $File::Properties::Error::Debug > 2B= defined $self->objectC= ref($self->object) =~ /^File::/
ABCresult
0XX0
10X0
1100
1111
54 and ref($self->object) =~ /^File::/) {
55 0 $txt .= "Exception occurred in object: " .$self->object . "\n";
56 0 ▶ if ($File::Properties::Error::Debug > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($File::Properties::Error::Debug > 3) 0 0 0
57 0 $txt .= "Object state:\n";
58 0 my ($k,$v);
59 0 foreach $k ( sort keys %{$self->object} ) {
60 0 ▶ $v = defined $self->object->{$k} ? $self->object->{$k} : "[undef]";
Branch: 1 branch
BranchTrueFalseTotal
defined $self->object->{$k} ? : 0 0 0
61 0 $txt .= " $k: $v\n";
62 }
63 }
64 }
65  
66 0 return $txt;
67 }
68  
69  
70 # ----------------------------------------------------------------------------
71 # End of method definitions
72 # ----------------------------------------------------------------------------
73  
74  
75 6 1;
76 __END__
↑ Summary blib/lib/File/Properties/Media.pm »