dodil/erp-brick-purchasing

DODIL ERP brick: purchasing

src/brick_purchasing/domain/errors.py

"""The refusals a rule makes. The use cases turn them into a 409 with these words, through both doors."""


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


class GateUnmet(RuleBroken):
    """A transition refused for readiness gates. The words are the readiness answer's own: gate, reason, fix."""

    def __init__(self, gates):
        self.gates = list(gates)
        super().__init__("; ".join(f"{g.gate}: {g.reason} (fix: {g.fix})" for g in self.gates))


class Invalid(RuleBroken):
    """An input outside its bounds or meaning (a 422): the field is named in the words."""