Skip to content

Cant Modify Immutable Attribute Error

Module for CantModifyImmutableAttributeError exception.

cant_modify_immutable_attribute_error

Module for CantModifyImmutableAttributeError exception.

CantModifyImmutableAttributeError

Bases: Error

Raised when there is an attempt to modify an immutable attribute of an object.

Source code in src/forging_blocks/foundation/errors/cant_modify_immutable_attribute_error.py
class CantModifyImmutableAttributeError(Error):
    """Raised when there is an attempt to modify an immutable attribute of an object."""

    def __init__(self, class_name: str, attribute_name: str):
        message = ErrorMessage(
            f"Cannot modify immutable attribute '{attribute_name}' of class '{class_name}'."
        )
        metadata = ErrorMetadata(
            {
                "class_name": class_name,
                "attribute_name": attribute_name,
            }
        )
        super().__init__(message, metadata)