errors – Exceptions raised by the pymongo package — PyMongo 2.7.2 documentation

# `errors` – Exceptions raised by the `pymongo` package

Exceptions raised by PyMongo.

exception `pymongo.errors.` `AutoReconnect`(message='', errors=None)

  Raised when a connection to the database is lost and an attempt to auto-reconnect will be made.

  In order to auto-reconnect you must handle this exception, recognizing that the operation which caused it has not necessarily succeeded. Future operations will attempt to open a new connection to the database (and will continue to raise this exception until the first successful connection is made).

exception `pymongo.errors.` `BulkWriteError`(results)

  Exception class for bulk write errors.

  New in version 2.7.

exception `pymongo.errors.` `CollectionInvalid`

  Raised when collection validation fails.

exception `pymongo.errors.` `ConfigurationError`

  Raised when something is incorrectly configured.

exception `pymongo.errors.` `ConnectionFailure`

  Raised when a connection to the database cannot be made or is lost.

exception `pymongo.errors.` `CursorNotFound`(error, code=None, details=None)

  Raised while iterating query results if the cursor is invalidated on the server.

  New in version 2.7.

exception `pymongo.errors.` `DocumentTooLarge`

  Raised when an encoded document is too large for the connected server.

exception `pymongo.errors.` `DuplicateKeyError`(error, code=None, details=None)

  Raised when a safe insert or update fails due to a duplicate key error.

  Note

  Requires server version >= 1.3.0

  New in version 1.4.

exception `pymongo.errors.` `ExceededMaxWaiters`

  Raised when a thread tries to get a connection from a pool and `max_pool_size * waitQueueMultiple` threads are already waiting.

  New in version 2.6.

exception `pymongo.errors.` `ExecutionTimeout`(error, code=None, details=None)

  Raised when a database operation times out, exceeding the $maxTimeMS set in the query or command option.

  Note

  Requires server version >= 2.6.0

  New in version 2.7.

exception `pymongo.errors.` `InvalidName`

  Raised when an invalid name is used.

exception `pymongo.errors.` `InvalidOperation`

  Raised when a client attempts to perform an invalid operation.

exception `pymongo.errors.` `InvalidURI`

  Raised when trying to parse an invalid mongodb URI.

  New in version 1.5.

exception `pymongo.errors.` `OperationFailure`(error, code=None, details=None)

  Raised when a database operation fails.

  New in version 2.7: The `details` attribute.

  New in version 1.8: The `code` attribute.

  `code`

    The error code returned by the server, if any.

  `details`

    The complete error document returned by the server.

    Depending on the error that occurred, the error document may include useful information beyond just the error message. When connected to a mongos the error document may contain one or more subdocuments if errors occurred on multiple shards.

exception `pymongo.errors.` `PyMongoError`

  Base class for all PyMongo exceptions.

  New in version 1.4.

exception `pymongo.errors.` `TimeoutError`(error, code=None, details=None)

  DEPRECATED - will be removed in PyMongo 3.0. See WTimeoutError instead.

  New in version 1.8.

exception `pymongo.errors.` `UnsupportedOption`

  Exception for unsupported options.

  New in version 2.0.

exception `pymongo.errors.` `WTimeoutError`(error, code=None, details=None)

  Raised when a database operation times out (i.e. wtimeout expires) before replication completes.

  With newer versions of MongoDB the details attribute may include write concern fields like ‘n’, ‘updatedExisting’, or ‘writtenTo’.

  New in version 2.7.