00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 """Exceptions raised by PyMongo."""
00016
00017 from bson.errors import *
00018
00019
00020 class PyMongoError(Exception):
00021 """Base class for all PyMongo exceptions.
00022
00023 .. versionadded:: 1.4
00024 """
00025
00026
00027 class ConnectionFailure(PyMongoError):
00028 """Raised when a connection to the database cannot be made or is lost.
00029 """
00030
00031
00032 class AutoReconnect(ConnectionFailure):
00033 """Raised when a connection to the database is lost and an attempt to
00034 auto-reconnect will be made.
00035
00036 In order to auto-reconnect you must handle this exception, recognizing that
00037 the operation which caused it has not necessarily succeeded. Future
00038 operations will attempt to open a new connection to the database (and
00039 will continue to raise this exception until the first successful
00040 connection is made).
00041 """
00042
00043
00044 class ConfigurationError(PyMongoError):
00045 """Raised when something is incorrectly configured.
00046 """
00047
00048
00049 class OperationFailure(PyMongoError):
00050 """Raised when a database operation fails.
00051
00052 .. versionadded:: 1.8
00053 The :attr:`code` attribute.
00054 """
00055
00056 def __init__(self, error, code=None):
00057 self.code = code
00058 PyMongoError.__init__(self, error)
00059
00060
00061 class TimeoutError(OperationFailure):
00062 """Raised when a database operation times out.
00063
00064 .. versionadded:: 1.8
00065 """
00066
00067
00068 class DuplicateKeyError(OperationFailure):
00069 """Raised when a safe insert or update fails due to a duplicate key error.
00070
00071 .. note:: Requires server version **>= 1.3.0**
00072
00073 .. versionadded:: 1.4
00074 """
00075
00076
00077 class InvalidOperation(PyMongoError):
00078 """Raised when a client attempts to perform an invalid operation.
00079 """
00080
00081
00082 class InvalidName(PyMongoError):
00083 """Raised when an invalid name is used.
00084 """
00085
00086
00087 class CollectionInvalid(PyMongoError):
00088 """Raised when collection validation fails.
00089 """
00090
00091
00092 class InvalidURI(ConfigurationError):
00093 """Raised when trying to parse an invalid mongodb URI.
00094
00095 .. versionadded:: 1.5
00096 """