1414
1515"""Exceptions raised by the Mongo driver."""
1616
17+ class BaseMongoDBException (Exception ):
18+ """Common base class for all MongoDB exceptions"""
1719
18- class ConnectionFailure (IOError ):
20+ class ConnectionFailure (BaseMongoDBException , IOError ):
1921 """Raised when a connection to the database cannot be made or is lost.
2022 """
2123
@@ -32,12 +34,12 @@ class AutoReconnect(ConnectionFailure):
3234 """
3335
3436
35- class ConfigurationError (Exception ):
37+ class ConfigurationError (BaseMongoDBException ):
3638 """Raised when something is incorrectly configured.
3739 """
3840
3941
40- class OperationFailure (Exception ):
42+ class OperationFailure (BaseMongoDBException ):
4143 """Raised when a database operation fails.
4244 """
4345
@@ -49,36 +51,36 @@ class DuplicateKeyError(OperationFailure):
4951 """
5052
5153
52- class InvalidOperation (Exception ):
54+ class InvalidOperation (BaseMongoDBException ):
5355 """Raised when a client attempts to perform an invalid operation.
5456 """
5557
5658
57- class CollectionInvalid (Exception ):
59+ class CollectionInvalid (BaseMongoDBException ):
5860 """Raised when collection validation fails.
5961 """
6062
6163
62- class InvalidName (ValueError ):
64+ class InvalidName (BaseMongoDBException , ValueError ):
6365 """Raised when an invalid name is used.
6466 """
6567
6668
67- class InvalidBSON (ValueError ):
69+ class InvalidBSON (BaseMongoDBException , ValueError ):
6870 """Raised when trying to create a BSON object from invalid data.
6971 """
7072
7173
72- class InvalidStringData (ValueError ):
74+ class InvalidStringData (BaseMongoDBException , ValueError ):
7375 """Raised when trying to encode a string containing non-UTF8 data.
7476 """
7577
7678
77- class InvalidDocument (ValueError ):
79+ class InvalidDocument (BaseMongoDBException , ValueError ):
7880 """Raised when trying to create a BSON object from an invalid document.
7981 """
8082
8183
82- class InvalidId (ValueError ):
84+ class InvalidId (BaseMongoDBException , ValueError ):
8385 """Raised when trying to create an ObjectId from invalid data.
8486 """
0 commit comments