errors – Exceptions raised by the bson package

Exceptions raised by the BSON package.

exception bson.errors.BSONError

Base class for all BSON exceptions.

exception bson.errors.InvalidBSON

Raised when trying to create a BSON object from invalid data.

exception bson.errors.InvalidDocument(message, document=None)

Raised when trying to create a BSON object from an invalid document.

Parameters:
  • message (str)

  • document (Optional[Any])

Return type:

None

property document: Any

The invalid document that caused the error.

..versionadded:: 4.16

exception bson.errors.InvalidId

Raised when trying to create an ObjectId from invalid data.

exception bson.errors.InvalidStringData

Raised when trying to encode a string containing non-UTF8 data.