xapian-core  1.4.25
Public Member Functions | Private Member Functions | List of all members
Xapian::ErrorHandler Class Referenceabstract

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

#include <errorhandler.h>

+ Inheritance diagram for Xapian::ErrorHandler:
+ Collaboration diagram for Xapian::ErrorHandler:

Public Member Functions

 ErrorHandler ()
 Default constructor. More...
 
virtual ~ErrorHandler ()
 We require a virtual destructor because we have virtual methods. More...
 
void operator() (Xapian::Error &error)
 Handle a Xapian::Error object. More...
 
ErrorHandlerrelease ()
 Start reference counting this object. More...
 
const ErrorHandlerrelease () const
 Start reference counting this object. More...
 
- Public Member Functions inherited from Xapian::Internal::opt_intrusive_base
 opt_intrusive_base (const opt_intrusive_base &)
 
opt_intrusive_baseoperator= (const opt_intrusive_base &)
 
 opt_intrusive_base ()
 Construct object which is initially not reference counted. More...
 
virtual ~opt_intrusive_base ()
 
void ref () const
 
void unref () const
 

Private Member Functions

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

Additional Inherited Members

- Public Attributes inherited from Xapian::Internal::opt_intrusive_base
unsigned _refs
 Reference count. More...
 
- Protected Member Functions inherited from Xapian::Internal::opt_intrusive_base
void release () const
 Start reference counting. More...
 

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 50 of file errorhandler.h.

Constructor & Destructor Documentation

◆ ErrorHandler() [1/2]

Xapian::ErrorHandler::ErrorHandler ( const Xapian::ErrorHandler )
private

Don't allow copying.

◆ ErrorHandler() [2/2]

Xapian::ErrorHandler::ErrorHandler ( )
inline

Default constructor.

Definition at line 81 of file errorhandler.h.

◆ ~ErrorHandler()

Xapian::ErrorHandler::~ErrorHandler ( )
virtual

We require a virtual destructor because we have virtual methods.

Definition at line 26 of file errorhandler.cc.

Member Function Documentation

◆ handle_error()

virtual bool Xapian::ErrorHandler::handle_error ( Xapian::Error error)
privatepure virtual

Perform user-specified error handling.

This virtual method must be defined by the API 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
errorThe Xapian::Error object under consideration.
Returns
true to attempt to continue; false to rethrow the error.

Referenced by operator()().

◆ 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
errorThe Xapian::Error object under consideration.

Definition at line 29 of file errorhandler.cc.

References Xapian::Error::already_handled, and handle_error().

◆ operator=()

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

Don't allow assignment.

◆ release() [1/2]

ErrorHandler* Xapian::ErrorHandler::release ( )
inline

Start reference counting this object.

You can hand ownership of a dynamically allocated ErrorHandler object to Xapian by calling release() and then passing the object to a Xapian method. Xapian will arrange to delete the object once it is no longer required.

Definition at line 105 of file errorhandler.h.

◆ release() [2/2]

const ErrorHandler* Xapian::ErrorHandler::release ( ) const
inline

Start reference counting this object.

You can hand ownership of a dynamically allocated ErrorHandler object to Xapian by calling release() and then passing the object to a Xapian method. Xapian will arrange to delete the object once it is no longer required.

Definition at line 117 of file errorhandler.h.


The documentation for this class was generated from the following files: