line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This is an exception handling module for File::Properties. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright © 2010,2011 Brendt Wohlberg |
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
|
|
|
|
|
|
|
our $VERSION = 0.01; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require 5.005; |
16
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
239
|
|
17
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
228
|
|
18
|
6
|
|
|
6
|
|
9938
|
use Error qw(:try); |
|
6
|
|
|
|
|
64811
|
|
|
6
|
|
|
|
|
59
|
|
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
6
|
|
1737
|
use base qw(Error); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
788
|
|
21
|
6
|
|
|
6
|
|
37
|
use overload ('""' => 'string'); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
39
|
|
22
|
|
|
|
|
|
|
$File::Properties::Error::Debug = 0; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
# Constructor |
27
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
28
|
|
|
|
|
|
|
sub new { |
29
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
my $text = "" . shift; |
31
|
0
|
|
|
|
|
|
my $obrf = shift; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
34
|
0
|
0
|
|
|
|
|
local $Error::Debug = 1 if ($File::Properties::Error::Debug > 1); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->SUPER::new('-text' => $text, '-object' => $obrf); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
41
|
|
|
|
|
|
|
# Construct string from object |
42
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
43
|
|
|
|
|
|
|
sub string { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $txt; |
47
|
0
|
0
|
|
|
|
|
if ($File::Properties::Error::Debug == 0) { |
48
|
0
|
|
|
|
|
|
$txt = $self->text . "\n"; |
49
|
|
|
|
|
|
|
} else { |
50
|
0
|
0
|
|
|
|
|
$txt = $self->stacktrace if ($File::Properties::Error::Debug); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
0
|
|
|
|
if ($File::Properties::Error::Debug > 2 and defined($self->object) |
|
|
|
0
|
|
|
|
|
54
|
|
|
|
|
|
|
and ref($self->object) =~ /^File::/) { |
55
|
0
|
|
|
|
|
|
$txt .= "Exception occurred in object: " .$self->object . "\n"; |
56
|
0
|
0
|
|
|
|
|
if ($File::Properties::Error::Debug > 3) { |
57
|
0
|
|
|
|
|
|
$txt .= "Object state:\n"; |
58
|
0
|
|
|
|
|
|
my ($k,$v); |
59
|
0
|
|
|
|
|
|
foreach $k ( sort keys %{$self->object} ) { |
|
0
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
$v = defined $self->object->{$k} ? $self->object->{$k} : "[undef]"; |
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
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |