"""
Exception hierarchy for Verisoo.

Follows the pattern established in the Soo Suite for typed, informative errors.
"""

from __future__ import annotations


class VerisooError(Exception):
    """Base exception for all Verisoo errors."""

    pass


class AttestationError(VerisooError):
    """Errors during attestation creation or signing."""

    pass


class VerificationError(VerisooError):
    """Errors during attestation verification."""

    def __init__(self, message: str, *, reason: str | None = None) -> None:
        super().__init__(message)
        self.reason = reason


class HashMismatchError(VerificationError):
    """Image hash does not match attestation record."""

    def __init__(
        self, message: str, *, expected: str, actual: str, hash_type: str
    ) -> None:
        super().__init__(message, reason="hash_mismatch")
        self.expected = expected
        self.actual = actual
        self.hash_type = hash_type


class SignatureError(VerificationError):
    """Signature verification failed."""

    def __init__(self, message: str) -> None:
        super().__init__(message, reason="invalid_signature")


class IdentityError(VerisooError):
    """Errors related to identity/key management."""

    pass


class MerkleError(VerisooError):
    """Errors in merkle tree operations."""

    pass


class FederationError(VerisooError):
    """Errors in peer communication and sync."""

    pass
