3
# Copyright (C) 2007 Lemur Consulting Ltd
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License along
16
# with this program; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
r"""errors.py: Exceptions for the search engine core.
21
__docformat__ = "restructuredtext en"
23
class SearchEngineError(Exception):
24
r"""Base class for exceptions thrown by the search engine.
26
Any errors generated by xappy itself, or by xapian, will be instances of
27
this class or its subclasses.
31
class IndexerError(SearchEngineError):
32
r"""Class used to report errors relating to the indexing API.
36
class SearchError(SearchEngineError):
37
r"""Class used to report errors relating to the search API.
42
class XapianError(SearchEngineError):
43
r"""Base class for exceptions thrown by the xapian.
45
Any errors generated by xapian will be instances of this class or its
50
def _rebase_xapian_exceptions():
51
"""Add new base classes for all the xapian exceptions.
57
'DatabaseCorruptError',
58
'DatabaseCreateError',
61
'DatabaseModifiedError',
62
'DatabaseOpeningError',
63
'DatabaseVersionError',
65
# We skip 'Error' because it inherits directly from exception
66
# and this causes problems with method resolution order.
67
# However, we probably don't need it anyway, because it's
68
# just a base class, and shouldn't ever actually be raised.
69
# Users can catch xappy.XapianError instead.
70
'FeatureUnavailableError',
72
'InvalidArgumentError',
73
'InvalidOperationError',
76
'NetworkTimeoutError',
82
xapian_exception = getattr(xapian, name, None)
83
if xapian_exception is not None:
84
xapian_exception.__bases__ += (XapianError, )
85
globals()['Xapian' + name] = xapian_exception
87
_rebase_xapian_exceptions()