Skip to content

Exceptions API

exceptions

Exception classes for Playfast.

Provides structured error handling for Google Play Store scraping operations.

PlayfastError

Bases: Exception

Base exception for all Playfast errors.

Source code in python/playfast/exceptions.py
class PlayfastError(Exception):
    """Base exception for all Playfast errors."""

AppNotFoundError

Bases: PlayfastError

Raised when an app cannot be found on Google Play.

Parameters:

Name Type Description Default
app_id str

The app ID that was not found

required
message str | None

Optional custom error message

None
Source code in python/playfast/exceptions.py
class AppNotFoundError(PlayfastError):
    """Raised when an app cannot be found on Google Play.

    Args:
        app_id: The app ID that was not found
        message: Optional custom error message

    """

    def __init__(self, app_id: str, message: str | None = None) -> None:
        self.app_id = app_id
        if message is None:
            message = f"App not found: {app_id}"
        super().__init__(message)

RateLimitError

Bases: PlayfastError

Raised when rate limit is exceeded.

Parameters:

Name Type Description Default
retry_after int

Seconds to wait before retrying

60
message str | None

Optional custom error message

None
Source code in python/playfast/exceptions.py
class RateLimitError(PlayfastError):
    """Raised when rate limit is exceeded.

    Args:
        retry_after: Seconds to wait before retrying
        message: Optional custom error message

    """

    def __init__(self, retry_after: int = 60, message: str | None = None) -> None:
        self.retry_after = retry_after
        if message is None:
            message = f"Rate limit exceeded. Retry after {retry_after} seconds."
        super().__init__(message)

ParseError

Bases: PlayfastError

Raised when HTML parsing fails.

This typically indicates that Google Play's page structure has changed or the response is not in the expected format.

Parameters:

Name Type Description Default
message str

Description of what failed to parse

required
html_snippet str | None

Optional snippet of the problematic HTML

None
Source code in python/playfast/exceptions.py
class ParseError(PlayfastError):
    """Raised when HTML parsing fails.

    This typically indicates that Google Play's page structure has changed
    or the response is not in the expected format.

    Args:
        message: Description of what failed to parse
        html_snippet: Optional snippet of the problematic HTML

    """

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

NetworkError

Bases: PlayfastError

Raised when network requests fail.

Parameters:

Name Type Description Default
url str

The URL that failed

required
status_code int | None

HTTP status code (if available)

None
message str | None

Optional custom error message

None
Source code in python/playfast/exceptions.py
class NetworkError(PlayfastError):
    """Raised when network requests fail.

    Args:
        url: The URL that failed
        status_code: HTTP status code (if available)
        message: Optional custom error message

    """

    def __init__(
        self,
        url: str,
        status_code: int | None = None,
        message: str | None = None,
    ) -> None:
        self.url = url
        self.status_code = status_code
        if message is None:
            if status_code:
                message = f"Network error {status_code} for URL: {url}"
            else:
                message = f"Network error for URL: {url}"
        super().__init__(message)

ValidationError

Bases: PlayfastError

Raised when data validation fails.

This is different from Pydantic's ValidationError - it's for business logic validation that happens before or after Pydantic.

Parameters:

Name Type Description Default
field str

The field that failed validation

required
value object

The invalid value

required
message str | None

Optional custom error message

None
Source code in python/playfast/exceptions.py
class ValidationError(PlayfastError):
    """Raised when data validation fails.

    This is different from Pydantic's ValidationError - it's for
    business logic validation that happens before or after Pydantic.

    Args:
        field: The field that failed validation
        value: The invalid value
        message: Optional custom error message

    """

    def __init__(self, field: str, value: object, message: str | None = None) -> None:
        self.field = field
        self.value = value
        if message is None:
            message = f"Validation failed for field '{field}': {value}"
        super().__init__(message)

TimeoutError

Bases: PlayfastError

Raised when an operation times out.

Parameters:

Name Type Description Default
operation str

Description of the operation that timed out

required
timeout float

The timeout value in seconds

required
Source code in python/playfast/exceptions.py
class TimeoutError(PlayfastError):
    """Raised when an operation times out.

    Args:
        operation: Description of the operation that timed out
        timeout: The timeout value in seconds

    """

    def __init__(self, operation: str, timeout: float) -> None:
        self.operation = operation
        self.timeout = timeout
        message = f"Operation '{operation}' timed out after {timeout} seconds"
        super().__init__(message)

options: show_source: true show_root_heading: true members: true