File Coverage

blib/lib/HTTP/OAI/Error.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition 3 5 60.0
subroutine 8 8 100.0
pod 5 6 83.3
total 35 38 92.1


line stmt bran cond sub pod time code
1             package HTTP::OAI::Error;
2              
3             @ISA = qw( HTTP::OAI::SAX::Base HTTP::OAI::MemberMixin Exporter );
4              
5 11     11   71 use strict;
  11         22  
  11         337  
6              
7 11     11   47 use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAG);
  11         20  
  11         3629  
8              
9             our $VERSION = '4.12';
10              
11             @EXPORT = qw();
12             @EXPORT_OK = qw(%OAI_ERRORS);
13             %EXPORT_TAG = ();
14              
15             my %OAI_ERRORS = (
16             badArgument => 'The request includes illegal arguments, is missing required arguments, includes a repeated argument, or values for arguments have an illegal syntax.',
17             # badGranularity => 'The values of the from and until arguments are illegal or specify a finer granularity than is supported by the repository.',
18             badResumptionToken => 'The value of the resumptionToken argument is invalid or expired.',
19             badVerb => 'Value of the verb argument is not a legal OAI-PMH verb, the verb argument is missing, or the verb argument is repeated.',
20             cannotDisseminateFormat => 'The metadata format identified by the value given for the metadataPrefix argument is not supported by the item or by the repository',
21             idDoesNotExist => 'The value of the identifier argument is unknown or illegal in this repository.',
22             noRecordsMatch => 'The combination of the values of the from, until, set, and metadataPrefix arguments results in an empty list.',
23             noMetadataFormats => 'There are no metadata formats available for the specified item.',
24             noSetHierarchy => 'The repository does not support sets.'
25             );
26              
27             sub new
28             {
29 6     6 1 20 my( $class, %self ) = @_;
30              
31 6 100 66     26 $self{message} ||= $OAI_ERRORS{$self{code}} if $self{code};
32              
33 6         32 return $class->SUPER::new(%self);
34             }
35              
36 12     12 1 190 sub code { shift->_elem('code',@_) }
37 7     7 1 65 sub message { shift->_elem('message',@_) }
38              
39             sub generate
40             {
41 1     1 0 2 my( $self, $driver ) = @_;
42              
43 1   50     7 $driver->data_element( 'error', ($self->message || $OAI_ERRORS{$self->code} || ''),
44             code => $self->code,
45             );
46             }
47              
48             sub start_element
49             {
50 2     2 1 47 my( $self, $hash ) = @_;
51              
52 2         5 $self->code( $hash->{Attributes}->{'{}code'}->{Value} );
53             }
54              
55             sub characters
56             {
57 2     2 1 39 my( $self, $hash ) = @_;
58              
59 2         6 $self->message( $hash->{Data} );
60             }
61              
62             1;
63              
64             __END__