Skip to main content
Version: Next

ApifyApiError

Error raised when the Apify API returns an error response.

Instantiating ApifyApiError dispatches to the subclass matching the HTTP status code (e.g. 404 → NotFoundError, any 5xx → ServerError). Unmapped statuses stay on ApifyApiError. Existing except ApifyApiError handlers keep working because every subclass inherits from this class.

The type, message and data fields from the response body are exposed for inspection but are treated as non-authoritative metadata — dispatch is driven by the status code only.

Hierarchy

Index

Methods

__init__

  • __init__(response, attempt, method): None
  • Initialize the API error from a failed response.


    Parameters

    • response: HttpResponse

      The failed HTTP response from the Apify API.

    • attempt: int

      The attempt number when the request failed (1-indexed).

    • optionalmethod: str = 'GET'

      The HTTP method of the failed request.

    Returns None

__new__

  • __new__(response, attempt, method): Self
  • Dispatch to the subclass matching the response's HTTP status code, if any.


    Parameters

    • response: HttpResponse
    • attempt: int
    • optionalmethod: str = 'GET'

    Returns Self

Page Options