"""Authentication exceptions for Platform-MCP."""


class AuthError(Exception):
    """Base authentication error."""

    def __init__(self, message: str, error_code: str | None = None):
        super().__init__(message)
        self.message = message
        self.error_code = error_code


class RefreshError(AuthError):
    """Token refresh failed."""

    def __init__(self, message: str = "Failed to refresh token"):
        super().__init__(message, error_code="refresh_failed")


class DeviceFlowExpiredError(AuthError):
    """Device authorization code has expired."""

    def __init__(self, message: str = "Device code has expired. Please try again."):
        super().__init__(message, error_code="expired_token")


class DeviceFlowDeniedError(AuthError):
    """User denied the device authorization request."""

    def __init__(self, message: str = "Authorization denied by user."):
        super().__init__(message, error_code="access_denied")


class InvalidCompletionCodeError(AuthError):
    """Completion code is invalid or malformed."""

    def __init__(self, message: str = "Invalid completion code"):
        super().__init__(message, error_code="invalid_grant")
