| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $txt = $self->text . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $txt = $self->stacktrace if ($File::Properties::Error::Debug); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($File::Properties::Error::Debug > 2 and defined($self->object) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$File::Properties::Error::Debug > 2 and defined $self->object and ref($self->object) =~ /^File::/
$File::Properties::Error::Debug > 2 and defined $self->object
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::/
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||