line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OAI::Error; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
108
|
use strict; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
587
|
|
4
|
14
|
|
|
14
|
|
75
|
use base qw( XML::SAX::Base Exporter ); |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
20452
|
|
5
|
|
|
|
|
|
|
our @EXPORT = ( |
6
|
|
|
|
|
|
|
); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::OAI::Error - OAI-PMH errors. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 new() |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
23
|
|
|
23
|
1
|
1054
|
my ( $class, %opts ) = @_; |
24
|
23
|
|
33
|
|
|
229
|
my $self = bless \%opts, ref( $class ) || $class; |
25
|
23
|
|
|
|
|
241
|
$self->{ tagStack } = []; |
26
|
23
|
|
|
|
|
72
|
$self->{ insideError } = 0; |
27
|
23
|
100
|
|
|
|
166
|
$self->{ errorCode } = '' if ! exists( $self->{ errorCode } ); |
28
|
23
|
100
|
|
|
|
128
|
$self->{ errorString } = '' if ! exists( $self->{ errorString } ); |
29
|
|
|
|
|
|
|
# do not initialize $self->{ HTTPError } |
30
|
23
|
|
|
|
|
92
|
return( $self ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 errorCode() |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Returns an OAI error if one was encountered, or the empty string if no errors |
36
|
|
|
|
|
|
|
were associated with the OAI request. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over 4 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
badArgument |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
badResumptionToken |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
badVerb |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
cannotDisseminateFormat |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
idDoesNotExist |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
noRecordsMatch |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
noMetadataFormats |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
noSetHierarchy |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
xmlParseError |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
For more information about these error codes see: |
79
|
|
|
|
|
|
|
L. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub errorCode { |
84
|
13
|
|
|
13
|
1
|
36
|
my ( $self, $code ) = @_; |
85
|
13
|
50
|
|
|
|
66
|
if ( $code ) { $self->{ errorCode } = $code; } |
|
0
|
|
|
|
|
0
|
|
86
|
13
|
|
|
|
|
112
|
return( $self->{ errorCode } ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 errorString() |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns a textual description of the error that was encountered, or an empty |
92
|
|
|
|
|
|
|
string if there was no error associated with the OAI request. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub errorString { |
97
|
9
|
|
|
9
|
1
|
27
|
my ( $self, $str ) = @_; |
98
|
9
|
50
|
|
|
|
45
|
if ( $str ) { $self->{ errorString } = $str; } |
|
0
|
|
|
|
|
0
|
|
99
|
9
|
|
|
|
|
62
|
return( $self->{ errorString } ); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 HTTPError() |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
In case of HTTP level errors, returns the associated HTTP::Response object. |
105
|
|
|
|
|
|
|
Otherwise C. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub HTTPError { |
111
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
112
|
0
|
0
|
|
|
|
0
|
return exists $self->{ HTTPError } ? $self->{ HTTPError } : undef; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 TODO |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SEE ALSO |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=over 4 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHORS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * Ed Summers |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
## internal stuff |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
## all children of Net::OAI::Base should call this to make sure |
137
|
|
|
|
|
|
|
## certain object properties are set |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub start_element { |
140
|
52030
|
|
|
52030
|
1
|
19313877
|
my ( $self, $element ) = @_; |
141
|
52030
|
|
|
|
|
91038
|
my $tagName = $element->{ Name }; |
142
|
52030
|
100
|
|
|
|
108905
|
if ( $tagName eq 'error' ) { |
143
|
3
|
|
|
|
|
13
|
$self->{ errorCode } = $element->{ Attributes }{ '{}code' }{ Value }; |
144
|
3
|
|
|
|
|
7
|
$self->{ insideError } = 1; |
145
|
3
|
|
|
|
|
14
|
Net::OAI::Harvester::debug( "caught error" ); |
146
|
|
|
|
|
|
|
} else { |
147
|
52027
|
|
|
|
|
170127
|
$self->SUPER::start_element( $element ); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub end_element { |
152
|
52030
|
|
|
52030
|
1
|
9717748
|
my ( $self, $element ) = @_; |
153
|
52030
|
|
|
|
|
79762
|
my $tagName = $element->{ Name }; |
154
|
52030
|
100
|
|
|
|
108160
|
if ( $tagName eq 'error' ) { |
155
|
3
|
|
|
|
|
12
|
$self->{ insideError } = 0; |
156
|
|
|
|
|
|
|
} else { |
157
|
52027
|
|
|
|
|
161896
|
$self->SUPER::end_element( $element ); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub characters { |
162
|
108135
|
|
|
108135
|
1
|
8945611
|
my ( $self, $characters ) = @_; |
163
|
108135
|
100
|
|
|
|
240045
|
if ( $self->{ insideError } ) { |
164
|
3
|
|
|
|
|
13
|
$self->{ errorString } .= $characters->{ Data }; |
165
|
|
|
|
|
|
|
} else { |
166
|
108132
|
|
|
|
|
309992
|
$self->SUPER::characters( $characters ); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |