"""GitHub-specific exception classes.

This module defines the exception hierarchy for GitHub integration errors.
All exceptions inherit from IntegrationError to allow catching all
integration errors with a single except clause.
"""

from integrations.common.exceptions import IntegrationError


class GitHubError(IntegrationError):
    """Base exception for GitHub integration errors."""

    pass


class GitHubAPIError(GitHubError):
    """Error communicating with GitHub API."""

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


class GitHubAuthError(GitHubError):
    """GitHub authentication or authorization error."""

    pass


class GitHubRateLimitError(GitHubError):
    """GitHub rate limit exceeded."""

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


class GitHubTokenExpiredError(GitHubAuthError):
    """GitHub access token has expired.

    This is a specific auth error that indicates the token needs to be refreshed.
    """

    def __init__(self, message: str = "GitHub access token has expired") -> None:
        super().__init__(message)
