Xapian::Error Class Reference

All exceptions thrown by Xapian are subclasses of Xapian::Error. More...

#include <error.h>

Inheritance diagram for Xapian::Error:

Inheritance graph
[legend]
Collaboration diagram for Xapian::Error:

Collaboration graph
[legend]
List of all members.

Public Member Functions

const char * get_type () const
 The type of this error (e.g. "DocNotFoundError".).
const std::string & get_msg () const
 Message giving details of the error, intended for human consumption.
const std::string & get_context () const
 Optional context information.
const char * get_error_string () const
 Returns any system error string associated with this exception.
int get_errno () const
 Optional value of 'errno' associated with this error.
std::string get_description () const
 Return a string describing this object.

Private Member Functions

void operator= (const Error &o)
 Don't allow assignment of the base class.
 Error (const std::string &msg_, const std::string &context_, const char *type_, const char *error_string_)
 

For internal use only.

Constructor for use by constructors of derived classes.


 Error (const std::string &msg_, const std::string &context_, const char *type_, int errno_)
 

For internal use only.

Constructor for use by constructors of derived classes.



Private Attributes

std::string msg
 Message giving details of the error, intended for human consumption.
std::string context
 Optional context information.
const char * type
 The type of this error (e.g. DocNotFoundError.).
int my_errno
 Optional value of 'errno' associated with this error.
std::string error_string
 The error string derived from my_errno.
bool already_handled
 True if this error has already been passed to an ErrorHandler.

Friends

class ErrorHandler

Detailed Description

All exceptions thrown by Xapian are subclasses of Xapian::Error.

This class can not be instantiated directly - instead a subclass should be used.

Definition at line 38 of file error.h.


Constructor & Destructor Documentation

Xapian::Error::Error ( const std::string &  msg_,
const std::string &  context_,
const char *  type_,
const char *  error_string_ 
) [private]

For internal use only.

Constructor for use by constructors of derived classes.

Definition at line 42 of file error.cc.

References error_string.

Xapian::Error::Error ( const std::string &  msg_,
const std::string &  context_,
const char *  type_,
int  errno_ 
) [inline, private]

For internal use only.

Constructor for use by constructors of derived classes.

Definition at line 94 of file error.h.


Member Function Documentation

void Xapian::Error::operator= ( const Error o  )  [private]

Don't allow assignment of the base class.

const char* Xapian::Error::get_type (  )  const [inline]

The type of this error (e.g. "DocNotFoundError".).

Definition at line 101 of file error.h.

Referenced by test_driver::runtest(), and serialise_error().

const std::string& Xapian::Error::get_msg (  )  const [inline]

Message giving details of the error, intended for human consumption.

Definition at line 104 of file error.h.

Referenced by DEFINE_TESTCASE(), main(), serialise_error(), test_qp_default_op1(), test_qp_flag_pure_not1(), test_qp_stem_all1(), test_qp_stopper1(), test_qp_value_customrange1(), test_qp_value_daterange1(), test_qp_value_range1(), test_qp_value_range2(), and test_queryparser1().

const std::string& Xapian::Error::get_context (  )  const [inline]

Optional context information.

This context is intended for use by Xapian::ErrorHandler (for example so it can know which remote server is unreliable and report the problem and remove that server from those being searched). But it's typically a plain-text string, and so also fit for human consumption.

Definition at line 113 of file error.h.

Referenced by serialise_error().

const char * Xapian::Error::get_error_string (  )  const

Returns any system error string associated with this exception.

The system error string may come from errno, h_errno (on UNIX), or GetLastError() (on MS Windows). If there is no associated system error string, NULL is returned.

Definition at line 51 of file error.cc.

References error(), error_string, my_errno, and om_tostring().

Referenced by get_description(), serialise_error(), and test_serialiseerror1().

int Xapian::Error::get_errno (  )  const [inline]

Optional value of 'errno' associated with this error.

If no 'errno' value is associated, returns 0. If the returned value is negative, it's a platform-specific error code (on UNIX, -h_errno; on MS Windows, -GetLastError()).

Deprecated:
This method is deprecated, because errno values aren't portable between platforms, so we can't serialise them when passing exceptions from a remote server to a client. Use the get_error_string() method instead.

Definition at line 140 of file error.h.

References my_errno.

Referenced by test_serialiseerror1().

string Xapian::Error::get_description (  )  const

Return a string describing this object.

Definition at line 110 of file error.cc.

References context, get_error_string(), msg, and type.

Referenced by QuartzDatabase::apply(), FlintDatabase::apply(), main(), test_driver::runtest(), test_qp_default_op1(), test_qp_flag_pure_not1(), test_qp_stem_all1(), test_qp_stopper1(), test_qp_value_customrange1(), test_qp_value_daterange1(), test_qp_value_range1(), test_qp_value_range2(), test_queryparser1(), test_serialiseerror1(), and test_termgen1().


Friends And Related Function Documentation

friend class ErrorHandler [friend]

Definition at line 40 of file error.h.


Member Data Documentation

std::string Xapian::Error::msg [private]

Message giving details of the error, intended for human consumption.

Definition at line 43 of file error.h.

Referenced by get_description().

std::string Xapian::Error::context [private]

Optional context information.

This context is intended for use by Xapian::ErrorHandler (for example so it can know which remote server is unreliable and report the problem and remove that server from those being searched). But it's typically a plain-text string, and so also fit for human consumption.

Definition at line 52 of file error.h.

Referenced by get_description().

const char* Xapian::Error::type [private]

The type of this error (e.g. DocNotFoundError.).

Definition at line 55 of file error.h.

Referenced by get_description().

int Xapian::Error::my_errno [private]

Optional value of 'errno' associated with this error.

If no value is associated, this member variable will be 0.

On UNIX, if this value is < 0, it's a negated h_errno value (giving an error from gethostbyname() or similar).

On Windows, if this value is < 0, it's a negated Windows error code (as given by GetLastError() or WSAGetLastError()).

NB We don't just call this member "errno" to avoid problems on platforms where errno is a preprocessor macro.

Definition at line 70 of file error.h.

Referenced by get_errno(), and get_error_string().

std::string Xapian::Error::error_string [mutable, private]

The error string derived from my_errno.

This string is generated from my_errno lazily.

Definition at line 76 of file error.h.

Referenced by Error(), and get_error_string().

bool Xapian::Error::already_handled [private]

True if this error has already been passed to an ErrorHandler.

Definition at line 79 of file error.h.


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.