Skip to content

Architecture Error

architecture_error

Architecture error for dependency direction violations.

Defines ArchitectureError, raised at class-definition time when a subclass
violates Clean Architecture dependency rules.

ArchitectureError

Bases: RuntimeErrorMixin, Error[MetadataValueType]

Raised when a subclass violates dependency direction rules.

Clean Architecture requires that dependencies flow inward: outer
layers may depend on inner layers, but never the reverse. This error
fires at class creation time via __init_subclass__ whenever a
subclass declares a dependency that points in the wrong direction.

Example
error = ArchitectureError("Widget depends on Domain — violates dependency direction rules.")
raise error
Source code in src/forging_blocks/foundation/errors/architecture_error.py
class ArchitectureError(RuntimeErrorMixin, Error[MetadataValueType]):
    """Raised when a subclass violates dependency direction rules.

    Clean Architecture requires that dependencies flow inward: outer
    layers may depend on inner layers, but never the reverse. This error
    fires at class creation time via ``__init_subclass__`` whenever a
    subclass declares a dependency that points in the wrong direction.

    Example:
        ```python
        error = ArchitectureError("Widget depends on Domain — violates dependency direction rules.")
        raise error
        ```


    """

    def __init__(self, message: str) -> None:
        """Initialise with a descriptive violation message.

        Args:
            message: Human-readable description of the violation,
                including the class name, the offending parameter,
                and the applicable rule.

        """
        super().__init__(ErrorMessage(message))

__init__(message: str) -> None

Initialise with a descriptive violation message.

Parameters:

Name Type Description Default
message str

Human-readable description of the violation,
including the class name, the offending parameter,
and the applicable rule.

required
Source code in src/forging_blocks/foundation/errors/architecture_error.py
def __init__(self, message: str) -> None:
    """Initialise with a descriptive violation message.

    Args:
        message: Human-readable description of the violation,
            including the class name, the offending parameter,
            and the applicable rule.

    """
    super().__init__(ErrorMessage(message))