@@ -11,20 +11,19 @@ class ApifyClientError(Exception):
1111
1212
1313class ApifyApiError (ApifyClientError ):
14- """Error specific to requests to the Apify API .
14+ """Error from Apify API responses (rate limits, validation errors, internal errors) .
1515
16- An `ApifyApiError` is thrown for successful HTTP requests that reach the API, but the API responds with
17- an error response. Typically, those are rate limit errors and internal errors, which are automatically retried,
18- or validation errors, which are thrown immediately, because a correction by the user is needed.
16+ Thrown when HTTP request succeeds but API returns an error response. Rate limit and internal errors are
17+ retried automatically, while validation errors are thrown immediately for user correction.
1918 """
2019
2120 def __init__ (self , response : impit .Response , attempt : int , method : str = 'GET' ) -> None :
22- """Initialize a new instance .
21+ """Initialize an API error from a failed response .
2322
2423 Args:
25- response: The response to the failed API call .
26- attempt: Which attempt was the request that failed.
27- method: The HTTP method used for the request .
24+ response: The failed API response .
25+ attempt: The attempt number when the request failed.
26+ method: The HTTP method used.
2827 """
2928 self .message : str | None = None
3029 self .type : str | None = None
@@ -48,25 +47,18 @@ def __init__(self, response: impit.Response, attempt: int, method: str = 'GET')
4847 self .attempt = attempt
4948 self .http_method = method
5049
51- # TODO: self.client_method # noqa: TD003
52- # TODO: self.original_stack # noqa: TD003
53- # TODO: self.path # noqa: TD003
54- # TODO: self.stack # noqa: TD003
55-
5650
5751class InvalidResponseBodyError (ApifyClientError ):
58- """Error caused by the response body failing to be parsed.
52+ """Error when response body cannot be parsed (e.g., partial JSON) .
5953
60- This error exists for the quite common situation, where only a partial JSON response is received and an attempt
61- to parse the JSON throws an error. In most cases this can be resolved by retrying the request. We do that by
62- identifying this error in the HTTPClient.
54+ Commonly occurs when only partial JSON is received. Usually resolved by retrying the request.
6355 """
6456
6557 def __init__ (self , response : impit .Response ) -> None :
6658 """Initialize a new instance.
6759
6860 Args:
69- response: The response which failed to be parsed .
61+ response: The response that failed to parse .
7062 """
7163 super ().__init__ ('Response body could not be parsed' )
7264
0 commit comments