dodil/erp-brick-gl

DODIL ERP brick: general ledger

src/brick_gl/domain/errors.py

"""The one refusal a rule makes. The use cases turn it into a 409 (or the status it names) with these words."""


class RuleBroken(Exception):
    """A business rule said no. The message is written for the person who tried.

    `status` is the HTTP status the doors answer: 409 for a state the world is in (a closed period), 422 for a request
    that can never be right (an unbalanced journal, an unmapped purpose)."""

    def __init__(self, message: str, status: int = 409, gate: str = ""):
        super().__init__(message)
        self.status, self.gate = status, gate