Skip to content

None Not Allowed Error

none_not_allowed_error

Error raised when None is passed where a non-null value is required.

Defines NoneNotAllowedError, used by validation guards and the
NoneNotAllowed predicate to enforce non-null constraints on method
parameters and field values. Extends ValueErrorMixin (catchable as
ValueError) and Error[str].

NoneNotAllowedError

Bases: ValueErrorMixin, Error[str]

Error indicating that a None value was provided where it is not allowed.

Example
error = NoneNotAllowedError(ErrorMessage("Value cannot be None"))
raise error
Source code in src/forging_blocks/foundation/errors/none_not_allowed_error.py
class NoneNotAllowedError(ValueErrorMixin, Error[str]):
    """Error indicating that a None value was provided where it is not allowed.

    Example:
        ```python
        error = NoneNotAllowedError(ErrorMessage("Value cannot be None"))
        raise error
        ```

    """