Xapian::ErrorHandler Class Reference

Decide if a Xapian::Error exception should be ignored. More...

#include <errorhandler.h>

List of all members.

Public Member Functions

 ErrorHandler ()
 Default constructor.
virtual ~ErrorHandler ()
 We require a virtual destructor because we have virtual methods.
void operator() (Xapian::Error &error)
 Handle a Xapian::Error object.

Private Member Functions

void operator= (const ErrorHandler &)
 Don't allow assignment.
 ErrorHandler (const Xapian::ErrorHandler &)
 Don't allow copying.
virtual bool handle_error (Xapian::Error &error)=0
 Perform user-specified error handling.


Detailed Description

Decide if a Xapian::Error exception should be ignored.

You can create your own subclass of this class and pass in an instance of it when you construct a Xapian::Enquire object. Xapian::Error exceptions which happen during the match process are passed to this object and it can decide whether they should propagate or whether Enquire should attempt to continue.

The motivation is to allow searching over remote databases to handle a remote server which has died (both to allow results to be returned, and also so that such errors can be logged and dead servers temporarily removed from use).

Definition at line 43 of file errorhandler.h.


Constructor & Destructor Documentation

Xapian::ErrorHandler::ErrorHandler ( const Xapian::ErrorHandler  )  [private]

Don't allow copying.

Xapian::ErrorHandler::ErrorHandler (  )  [inline]

Default constructor.

Definition at line 73 of file errorhandler.h.

Xapian::ErrorHandler::~ErrorHandler (  )  [virtual]

We require a virtual destructor because we have virtual methods.

Definition at line 25 of file errorhandler.cc.


Member Function Documentation

void Xapian::ErrorHandler::operator= ( const ErrorHandler  )  [private]

Don't allow assignment.

virtual bool Xapian::ErrorHandler::handle_error ( Xapian::Error error  )  [private, pure virtual]

Perform user-specified error handling.

This virtual method must be defined by the APU user to specify how a Xapian::Error is to be handled.

If you want execution to continue (where possible), then return true. If you want the Error to be rethrown and propagate out of the library, then return false.

Note that it's not always possible to continue execution, so the error may be rethrown even if you return true. The ErrorHandler is still called in this situation as you may want to log that a particular remote backend server isn't responding, and perhaps remove it from those being searched temporarily.

Parameters:
error The Xapian::Error object under consideration.
Returns:
true to attempt to continue; false to rethrow the error.

Referenced by operator()().

void Xapian::ErrorHandler::operator() ( Xapian::Error error  ) 

Handle a Xapian::Error object.

This method is called when a Xapian::Error object is thrown and caught inside Enquire. If this is the first ErrorHandler that the Error has been passed to, then the handle_error() virtual method is called, which allows the API user to decide how to handle the error.

Parameters:
error The Xapian::Error object under consideration.

Definition at line 28 of file errorhandler.cc.

References error(), and handle_error().


The documentation for this class was generated from the following files:
Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.