Net::OAI::Error - OAI-PMH errors.


OAI-Harvester documentation Contained in the OAI-Harvester distribution.

Index


Code Index:

NAME

Top

Net::OAI::Error - OAI-PMH errors.

SYNOPSIS

Top

DESCRIPTION

Top

METHODS

Top

new()

errorCode()

Returns an OAI error if one was encountered, or the empty string if no errors were associated with the OAI request.

badArgument

badResumptionToken

badVerb

cannotDisseminateFormat

idDoesNotExist

noRecordsMatch

noMetadataFormats

noSetHierarchy

xmlParseError

For more information about these error codes see: http://www.openarchives.org/OAI/openarchivesprotocol.html#ErrorConditions.

errorString()

Returns a textual description of the error that was encountered, or an empty string if there was no error associated with the OAI request.

HTTPError()

In case of HTTP level errors, returns the associated HTTP::Response object. Otherwise undef.

TODO

Top

SEE ALSO

Top

AUTHORS

Top

* Ed Summers <ehs@pobox.com>

OAI-Harvester documentation Contained in the OAI-Harvester distribution.
package Net::OAI::Error;

use strict;
use base qw( XML::SAX::Base Exporter );
our @EXPORT = (
);

sub new {
    my ( $class, %opts ) = @_;
    my $self = bless \%opts, ref( $class ) || $class;
    $self->{ tagStack } = [];
    $self->{ insideError } = 0; 
    $self->{ errorCode } = '' if ! exists( $self->{ errorCode } );
    $self->{ errorString }  = '' if ! exists( $self->{ errorString } );
# do not initialize $self->{ HTTPError }
    return( $self );
}

sub errorCode {
    my ( $self, $code ) = @_;
    if ( $code ) { $self->{ errorCode } = $code; }
    return( $self->{ errorCode } );
}

sub errorString {
    my ( $self, $str ) = @_;
    if ( $str ) { $self->{ errorString } = $str; }
    return( $self->{ errorString } );
}

sub HTTPError {
    my ( $self ) = @_;
    return exists $self->{ HTTPError } ? $self->{ HTTPError } : undef;
}


## internal stuff

## all children of Net::OAI::Base should call this to make sure
## certain object properties are set

sub start_element { 
    my ( $self, $element ) = @_;
    my $tagName = $element->{ Name };
    if ( $tagName eq 'error' ) {
	$self->{ errorCode } = $element->{ Attributes }{ '{}code' }{ Value };
	$self->{ insideError } = 1;
        Net::OAI::Harvester::debug( "caught error" );
    } else { 
	$self->SUPER::start_element( $element );
    }
}

sub end_element {
    my ( $self, $element ) = @_;
    my $tagName = $element->{ Name };
    if ( $tagName eq 'error' ) {
	$self->{ insideError } = 0;
    } else {
	$self->SUPER::end_element( $element );
    }
}

sub characters {
    my ( $self, $characters ) = @_;
    if ( $self->{ insideError } ) { 
	$self->{ errorString } .= $characters->{ Data };
    } else { 
	$self->SUPER::characters( $characters );
    }
}

1;