errors – Exceptions raised by the pymongo package

Exceptions raised by PyMongo.

exception pymongo.errors.AutoReconnect

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.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.DuplicateKeyError

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.InvalidBSON
Raised when trying to create a BSON object from invalid data.
exception pymongo.errors.InvalidDocument
Raised when trying to create a BSON object from an invalid document.
exception pymongo.errors.InvalidId
Raised when trying to create an ObjectId from invalid data.
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.InvalidStringData
Raised when trying to encode a string containing non-UTF8 data.
exception pymongo.errors.InvalidURI

Raised when trying to parse an invalid mongodb URI.

New in version 1.5.

exception pymongo.errors.OperationFailure
Raised when a database operation fails.
exception pymongo.errors.PyMongoError

Base class for all PyMongo exceptions.

New in version 1.4.

Previous topic

cursor – Tools for iterating over MongoDB query results

Next topic

master_slave_connection – Master-slave connection to MongoDB

This Page