monkey.dao.errors
Provides custom exception classes to handle errors arising from persistence-related operations.
This module defines base and specific exceptions to enable robust error handling in persistence
scenarios. The base class PersistenceError covers generic persistence issues, while
DuplicateKeyError and ObjectNotFoundError address specific cases like duplicate entries
and missing records respectively.
Classes:
-
DuplicateKeyError–This exception is raised when trying to insert a record with a key that already exists in the data collection.
-
ObjectNotFoundError–This exception is raised when trying to find a single record in a data set that does not exist.
-
PersistenceError–Represents an error related to persistence operations.
-
UnsupportedFeatureError–Represents an error to raise when attempting to use an unsupported feature.
monkey.dao.errors.DuplicateKeyError
DuplicateKeyError(data_collection, key: Any, cause=None)
Bases: PersistenceError
This exception is raised when trying to insert a record with a key that already exists in the data collection.
Represents an exception raised when a duplicate key is encountered in a data collection.
Parameters:
-
data_collection–The data collection in which the duplicate key was encountered.
-
key(Any) –The key that was already present in the data collection.
Attributes:
-
cause– -
data_collection– -
key– -
message–
monkey.dao.errors.DuplicateKeyError.cause
instance-attribute
cause = cause
monkey.dao.errors.DuplicateKeyError.data_collection
instance-attribute
data_collection = data_collection
monkey.dao.errors.DuplicateKeyError.key
instance-attribute
key = key
monkey.dao.errors.DuplicateKeyError.message
instance-attribute
message = message
monkey.dao.errors.ObjectNotFoundError
ObjectNotFoundError(data_collection, key: Any, cause=None)
Bases: PersistenceError
This exception is raised when trying to find a single record in a data set that does not exist.
Exception raised when an object is not found in the specified data set for a given key.
Parameters:
-
data_collection–The data collection in which the object was not found.
-
key(Any) –The key of the object that was not found.
-
cause–The optional cause of the error.
Attributes:
monkey.dao.errors.ObjectNotFoundError.cause
instance-attribute
cause = cause
monkey.dao.errors.ObjectNotFoundError.data_set
instance-attribute
data_set = data_collection
monkey.dao.errors.ObjectNotFoundError.key
instance-attribute
key = key
monkey.dao.errors.ObjectNotFoundError.message
instance-attribute
message = message
monkey.dao.errors.PersistenceError
PersistenceError(message='Persistence error', cause=None)
Bases: Exception
Represents an error related to persistence operations.
This class is designed to encapsulate errors that occur during persistence operations, such as saving or retrieving data. It provides the means to pass a custom error message and an optional cause, offering more insight into what caused the error. This aids in debugging and understanding context in persistence-related failures.
Represents an error related to persistence operations.
This class extends the base Exception class to provide additional context for persistence-related errors, allowing an optional cause to be specified.
Parameters:
-
message–The message describing the error.
-
cause–The optional cause of the error.
Attributes:
monkey.dao.errors.PersistenceError.cause
instance-attribute
cause = cause
monkey.dao.errors.PersistenceError.message
instance-attribute
message = message
monkey.dao.errors.UnsupportedFeatureError
UnsupportedFeatureError(
message="Unsupported feature", cause=None
)
Bases: Exception
Represents an error to raise when attempting to use an unsupported feature.
This exception is used to indicate that a certain feature is not supported within the current implementation. It provides an error message and an optional cause to give further context about the nature of the error.
Attributes:
Represents an error to raise when attempting to use a feature that is not supported by the implementation.
This class extends the base Exception class to provide additional context.
Parameters:
-
message–The message describing the error.
-
cause–The optional cause of the error.
monkey.dao.errors.UnsupportedFeatureError.cause
instance-attribute
cause = cause
monkey.dao.errors.UnsupportedFeatureError.message
instance-attribute
message = message