~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/support/xappy/errors.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
#
3
 
# Copyright (C) 2007 Lemur Consulting Ltd
4
 
#
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.
9
 
#
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.
14
 
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.
19
 
 
20
 
"""
21
 
__docformat__ = "restructuredtext en"
22
 
 
23
 
class SearchEngineError(Exception):
24
 
    r"""Base class for exceptions thrown by the search engine.
25
 
 
26
 
    Any errors generated by xappy itself, or by xapian, will be instances of
27
 
    this class or its subclasses.
28
 
 
29
 
    """
30
 
 
31
 
class IndexerError(SearchEngineError):
32
 
    r"""Class used to report errors relating to the indexing API.
33
 
 
34
 
    """
35
 
 
36
 
class SearchError(SearchEngineError):
37
 
    r"""Class used to report errors relating to the search API.
38
 
 
39
 
    """
40
 
 
41
 
 
42
 
class XapianError(SearchEngineError):
43
 
    r"""Base class for exceptions thrown by the xapian.
44
 
 
45
 
    Any errors generated by xapian will be instances of this class or its
46
 
    subclasses.
47
 
 
48
 
    """
49
 
 
50
 
def _rebase_xapian_exceptions():
51
 
    """Add new base classes for all the xapian exceptions.
52
 
 
53
 
    """
54
 
    import xapian
55
 
    for name in (
56
 
                 'AssertionError',
57
 
                 'DatabaseCorruptError',
58
 
                 'DatabaseCreateError',
59
 
                 'DatabaseError',
60
 
                 'DatabaseLockError',
61
 
                 'DatabaseModifiedError',
62
 
                 'DatabaseOpeningError',
63
 
                 'DatabaseVersionError',
64
 
                 'DocNotFoundError',
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',
71
 
                 'InternalError',
72
 
                 'InvalidArgumentError',
73
 
                 'InvalidOperationError',
74
 
                 'LogicError',
75
 
                 'NetworkError',
76
 
                 'NetworkTimeoutError',
77
 
                 'QueryParserError',
78
 
                 'RangeError',
79
 
                 'RuntimeError',
80
 
                 'UnimplementedError',
81
 
                 ):
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
86
 
 
87
 
_rebase_xapian_exceptions()