xapian-core  2.0.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Xapian::Error Class Reference

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

#include <error.h>

+ Inheritance diagram for Xapian::Error:
+ Collaboration diagram for Xapian::Error:

Public Member Functions

 Error (const Error &)=default
 Default copy constructor. More...
 
const char * get_type () const noexcept
 The type of this error (e.g. "DocNotFoundError".) More...
 
const std::string & get_msg () const noexcept
 Message giving details of the error, intended for human consumption. More...
 
const std::string & get_context () const noexcept
 Optional context information. More...
 
const char * get_error_string () const
 Returns any system error string associated with this exception. More...
 
std::string get_description () const
 Return a string describing this object. More...
 

Private Member Functions

void operator= (const Error &o)
 Don't allow assignment of the base class. More...
 
 Error (std::string_view msg_, std::string_view context_, const char *type_, const char *error_string_)
 Constructor for use by constructors of derived classes. More...
 
 Error (std::string_view msg_, std::string_view context_, const char *type_, int errno_)
 Constructor for use by constructors of derived classes. More...
 

Private Attributes

std::string msg
 Message giving details of the error, intended for human consumption. More...
 
std::string context
 Optional context information. More...
 
std::string error_string
 The error string derived from my_errno. More...
 
const char * type
 The type of this error (e.g. DocNotFoundError.) More...
 
int my_errno
 Optional value of 'errno' associated with this error. More...
 

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 41 of file error.h.

Constructor & Destructor Documentation

◆ Error() [1/3]

Xapian::Error::Error ( std::string_view  msg_,
std::string_view  context_,
const char *  type_,
const char *  error_string_ 
)
private

Constructor for use by constructors of derived classes.

Definition at line 41 of file error.cc.

References error_string.

◆ Error() [2/3]

Xapian::Error::Error ( std::string_view  msg_,
std::string_view  context_,
const char *  type_,
int  errno_ 
)
inlineprivate

Constructor for use by constructors of derived classes.

Definition at line 92 of file error.h.

◆ Error() [3/3]

Xapian::Error::Error ( const Error )
default

Default copy constructor.

We explicitly specify this to avoid warnings from GCC 9 (from -Wdeprecated-copy which is enabled by -Wextra).

Member Function Documentation

◆ get_context()

const std::string& Xapian::Error::get_context ( ) const
inlinenoexcept

Optional context information.

This context is intended for machine use (for example to know which remote server an error came from), but it is typically a plain-text string, and so also fit for human consumption.

Definition at line 121 of file error.h.

Referenced by DEFINE_TESTCASE(), and serialise_error().

◆ get_description()

string Xapian::Error::get_description ( ) const

Return a string describing this object.

Definition at line 93 of file error.cc.

References description_append().

Referenced by GlassDatabase::apply(), check_db_dir(), DEFINE_TESTCASE(), RemoteTcpServer::handle_one_connection(), main(), test_driver::runtest(), and show_db_stats().

◆ get_error_string()

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 50 of file error.cc.

References errno_to_string(), and Xapian::Internal::str().

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

◆ get_msg()

const std::string& Xapian::Error::get_msg ( ) const
inlinenoexcept

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

Definition at line 111 of file error.h.

Referenced by DEFINE_TESTCASE(), GlassDatabase::modifications_failed(), serialise_error(), show_db_stats(), test_weight_class(), test_weight_class_no_params(), and Xapian::DatabaseMaster::write_changesets_to_fd().

◆ get_type()

const char* Xapian::Error::get_type ( ) const
inlinenoexcept

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

Definition at line 106 of file error.h.

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

◆ operator=()

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

Don't allow assignment of the base class.

Member Data Documentation

◆ context

std::string Xapian::Error::context
private

Optional context information.

This context is intended for machine use (for example to know which remote server an error came from), but it is typically a plain-text string, and so also fit for human consumption.

Definition at line 51 of file error.h.

◆ error_string

std::string Xapian::Error::error_string
mutableprivate

The error string derived from my_errno.

This string is generated from my_errno lazily.

Definition at line 57 of file error.h.

Referenced by Error().

◆ msg

std::string Xapian::Error::msg
private

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

Definition at line 43 of file error.h.

◆ my_errno

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 an error code returned from getaddrinfo() (negated if such error codes are positive).

On Windows, if this value is < 0, it's a negated Windows error code (as given by GetLastError()), while if it is >= WSABASEERR then it is a WinSock error code (as given by WSAGetLastError()). Prior to Xapian 1.2.20 and 1.3.3, WSAGetLastError() codes were also negated.

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

Definition at line 77 of file error.h.

◆ type

const char* Xapian::Error::type
private

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

Definition at line 60 of file error.h.


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