Skip to content

Entity Id Deletion Error

entity_id_deletion_error

Module defining the EntityIdDeletionError exception.

EntityIdDeletionError

Bases: Error[dict[str, object]]

Raised when there is an attempt to delete an entity's identifier.

Source code in src/forging_blocks/domain/errors/entity_id_deletion_error.py
class EntityIdDeletionError(Error[dict[str, object]]):
    """Raised when there is an attempt to delete an entity's identifier."""

    def __init__(self, class_name: str) -> None:
        """Initialise the error with the class name.

        Args:
            class_name: Name of the class whose identifier was targeted for deletion.
        """
        message = ErrorMessage(
            f"Cannot delete 'id' of {class_name} as it defines the entity's identity."
        )
        metadata = ErrorMetadata[dict[str, object]](
            {
                "class_name": class_name,
                "attribute_name": "id",
            }
        )
        super().__init__(message, metadata)

__init__(class_name: str) -> None

Initialise the error with the class name.

Parameters:

Name Type Description Default
class_name str

Name of the class whose identifier was targeted for deletion.

required
Source code in src/forging_blocks/domain/errors/entity_id_deletion_error.py
def __init__(self, class_name: str) -> None:
    """Initialise the error with the class name.

    Args:
        class_name: Name of the class whose identifier was targeted for deletion.
    """
    message = ErrorMessage(
        f"Cannot delete 'id' of {class_name} as it defines the entity's identity."
    )
    metadata = ErrorMetadata[dict[str, object]](
        {
            "class_name": class_name,
            "attribute_name": "id",
        }
    )
    super().__init__(message, metadata)