| WebService-Lucene documentation | Contained in the WebService-Lucene distribution. |
WebService::Lucene::Exception - Exceptions to catch from the web service
my $entry = eval { $index->get_document( 1 ); };
if( my $e = WebService::Lucene::Exception->caught ) {
# handle exception
}
Object thrown for all exceptions from the web service.
Constructs a new exception from an HTTP::Response.
The HTTP::Response object passed to this exception.
The XML::Atom Entry for the error returned from the server.
If debug mode is enabled, a full stracktrace from the server-side will be found here.
Returns the type of exception the lucene web service has thrown.
Subclassed method to store an arrayref of extra fields.
Copyright 2006-2009 National Adult Literacy Database
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| WebService-Lucene documentation | Contained in the WebService-Lucene distribution. |
package WebService::Lucene::Exception; use strict; use warnings; use Exception::Class 'WebService::Lucene::Exception' => { fields => [ qw( response entry stacktrace type ) ] }; use base qw( Exception::Class::Base ); use XML::Atom::Entry;
sub new { my ( $class, $response ) = @_; my $self = $class->SUPER::new; $self->{ response } = $response; my $entry = eval { XML::Atom::Entry->new( \$response->content ) }; # if lucene-ws is broken, we won't get an XML::Atom::Entry if ( !$entry ) { $self->{ message } = $response->message; return $self; } $self->{ entry } = $entry; $self->{ message } = $entry->summary; $self->{ type } = $entry->title; my $content = $entry->content; if ( $content->type eq 'html' ) { $self->{ statcktrace } = $content->body; } return $self; }
1;