dodil/erp-brick-pos
DODIL ERP brick: point of sale
src/brick_pos/domain/errors.py
"""The refusals a rule makes. The use cases turn them into the status and the words a person reads, through both doors."""
from typing import Optional
class RuleBroken(Exception):
"""A business rule said no (409). The message is written for the person who tried; a `gate` and a `fix` let a caller
that acts on a refusal by rule (a screen's readiness panel, an agent) tell which rule and what to do."""
def __init__(self, message: str, *, gate: Optional[str] = None, fix: Optional[str] = None):
super().__init__(message)
self.gate, self.fix = gate, fix
class OutOfBounds(RuleBroken):
"""An amount or a count the books cannot hold: negative where it cannot be, past NUMERIC(18,2), or with more
decimals than the currency's minor unit. Answered 422 {gate: bounds}, never a 500 from the engine."""
def __init__(self, message: str):
super().__init__(message, gate="bounds", fix="send an exact decimal inside the limits the message names")