line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2553
|
use Error::Simple; |
|
1
|
|
|
|
|
227
|
|
|
1
|
|
|
|
|
11
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
perfSONAR_PS::Error - A module that provides the exceptions framework for perfSONAR PS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This module provides the base object for all exception types that will be presented. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# first define the errors somewhere |
14
|
|
|
|
|
|
|
package Some::Error; |
15
|
|
|
|
|
|
|
use base "Error::Simple"; |
16
|
|
|
|
|
|
|
1; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Some::Error; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# you MUST import this, otherwise the try/catch blocks will fail |
22
|
|
|
|
|
|
|
use Error qw(:try); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# if an error occurs, perfSONAR_PS objects should throw an error eg |
25
|
|
|
|
|
|
|
sub openDB { |
26
|
|
|
|
|
|
|
my $handle = undef; |
27
|
|
|
|
|
|
|
$handle = DBI->connect( ... ) |
28
|
|
|
|
|
|
|
or throw Some::Error( "Could not connect to database: " . $DBI::errstr . "\n" ); |
29
|
|
|
|
|
|
|
return $handle; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
### script.pl ### |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# in the calling code |
36
|
|
|
|
|
|
|
my $dbh = undef; |
37
|
|
|
|
|
|
|
try { |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$dbh = &openDB(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
catch Some::Error with { |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# print the contents of the error object (the string) |
45
|
|
|
|
|
|
|
print "An error occurred $@\n"; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
otherwise { |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# some other error occured! |
51
|
|
|
|
|
|
|
print "Some unknown error occurred! $@\n"; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
finally { |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
print "Done!\n"' |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# don't forget the trailing ';' |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
package perfSONAR_PS::Error; |
68
|
1
|
|
|
1
|
|
70
|
use base "Error"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
365
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
our $VERSION = 0.09; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new |
75
|
|
|
|
|
|
|
{ |
76
|
1
|
|
|
1
|
1
|
993
|
my $self = shift; |
77
|
1
|
|
|
|
|
3
|
my $text = "" . shift; |
78
|
1
|
|
|
|
|
2
|
my @args = (); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
2
|
local $Error::Depth = $Error::Depth + 1; |
81
|
1
|
|
|
|
|
1
|
local $Error::Debug = 1; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
9
|
$self->SUPER::new( -text => $text, @args ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 toEventType |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
returns the perfsonar event type for this exception as a string, ensure that |
90
|
|
|
|
|
|
|
you throw the appropriate inheritied exception object for automatic eventType |
91
|
|
|
|
|
|
|
creation. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
sub eventType |
95
|
|
|
|
|
|
|
{ |
96
|
1
|
|
|
1
|
0
|
480
|
my $self = shift; |
97
|
1
|
|
|
|
|
2
|
my $ex = ref $self; |
98
|
|
|
|
|
|
|
# form the '.' notation for the exceptions |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# ensure that camel cased words are separated |
101
|
1
|
|
|
|
|
3
|
my $s = undef; |
102
|
1
|
|
|
|
|
12
|
( $s = ref $self ) =~ s/([a-z])([A-Z])/$1_$2/g; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# remove perfSONAR_PS |
105
|
1
|
|
|
|
|
5
|
my @str = split /\:\:/, lc $s; |
106
|
1
|
|
|
|
|
2
|
shift @str; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
6
|
return join '.', @str; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 errorMessage |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
returns the error message itself (also the same as casting the object as a string) |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
sub errorMessage |
117
|
|
|
|
|
|
|
{ |
118
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
119
|
0
|
|
|
|
|
|
return $self->text(); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SEE ALSO |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L, L |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
To join the 'perfSONAR-PS' mailing list, please visit: |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
https://mail.internet2.edu/wws/info/i2-perfsonar |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The perfSONAR-PS subversion repository is located at: |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
https://svn.internet2.edu/svn/perfSONAR-PS |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Questions and comments can be directed to the author, or the mailing list. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 VERSION |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$Id$ |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Yee-Ting Li |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 LICENSE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
You should have received a copy of the Internet2 Intellectual Property Framework along |
153
|
|
|
|
|
|
|
with this software. If not, see |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 COPYRIGHT |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (c) 2004-2007, Internet2 and the University of Delaware |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
All rights reserved. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|