class AppError(Exception):
    """Base application error."""


class SettingsError(AppError):
    """Configuration is missing or invalid."""


class ProxmoxError(AppError):
    """Base error raised while talking to Proxmox."""


class ProxmoxTransportError(ProxmoxError):
    """Transport-level failure while talking to Proxmox."""


class ProxmoxConnectError(ProxmoxTransportError):
    """DNS or TCP connection failure."""


class ProxmoxTlsError(ProxmoxTransportError):
    """TLS handshake or certificate verification failure."""


class ProxmoxAuthError(ProxmoxError):
    """Authentication failure."""


class ProxmoxApiError(ProxmoxError):
    """Unexpected HTTP response from the API."""

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


class ProxmoxUnexpectedResponseError(ProxmoxError):
    """The API returned an unexpected payload shape."""


class ProxmoxPostCreateError(ProxmoxError):
    """A follow-up step failed after the VM already existed."""

    def __init__(self, node: str, vmid: int, step: str, message: str) -> None:
        super().__init__(message)
        self.node = node
        self.vmid = vmid
        self.step = step
