"""Exception hierarchy for the FablePool reference node.""" class FablePoolError(Exception): """Base class for all FablePool errors.""" class WireError(FablePoolError): """A wire-format violation: bad envelope, bad body schema, bad encoding.""" class SignatureError(FablePoolError): """A signature failed to verify, or an author identifier is malformed.""" class ChainError(FablePoolError): """The per-author hash chain in the operation log is broken.""" class StoreError(FablePoolError): """A semantic violation against the materialized store (e.g. refuting an already-refuted claim, missing inputs).""" class NotFoundError(StoreError): """No object matches the given identifier or prefix.""" def __init__(self, ref: str): super().__init__(f"no object matches identifier {ref!r}") self.ref = ref class AmbiguousIdError(StoreError): """An identifier prefix matches more than one object.""" def __init__(self, ref: str, matches): matches = sorted(matches) shown = ", ".join(matches[:6]) more = "" if len(matches) <= 6 else f" (+{len(matches) - 6} more)" super().__init__( f"identifier prefix {ref!r} is ambiguous: matches {shown}{more}" ) self.ref = ref self.matches = matches