
    i?1i                    n    d dl mZ d dlZd dlmZ  G d de      Z G d de      Z G d d	e      Zdd
Z	y)    )annotationsN)ignore_docsc                      e Zd ZdZy)ApifyClientErrorz7Base class for errors specific to the Apify API Client.N)__name__
__module____qualname____doc__     ^/home/www/therecruiter.miabetepe.com/venv/lib/python3.12/site-packages/apify_client/_errors.pyr   r      s    Ar   r   c                  .     e Zd ZdZed fd       Z xZS )ApifyApiErroraz  Error specific to requests to the Apify API.

    An `ApifyApiError` is thrown for successful HTTP requests that reach the API,
    but the API responds with an error response. Typically, those are rate limit
    errors and internal errors, which are automatically retried, or validation
    errors, which are thrown immediately, because a correction by the user is needed.
    c                l   d| _         d| _        d|j                   | _         	 |j                         }d|v r|d   d   | _         |d   d   | _        t
        |   | j                          d| _        |j                  | _        || _	        |j                  j                  | _        y# t        $ r Y _w xY w)zCreate the ApifyApiError instance.

        Args:
            response (httpx.Response): The response to the failed API call
            attempt (int): Which attempt was the request that failed
        NzUnexpected error: errormessagetyper   )r   r   textjson
ValueErrorsuper__init__namestatus_codeattemptrequestmethodhttp_method)selfresponser   response_data	__class__s       r   r   zApifyApiError.__init__   s     $( $	+HMM?;	$MMOM-',W5i@)'26:	 	&#	#//#++22  		s   .B' '	B32B3)r   r   r    httpx.Responser   intreturnNoner   r   r	   r
   r   r   __classcell__r"   s   @r   r   r      s     3 3r   r   c                  .     e Zd ZdZed fd       Z xZS )InvalidResponseBodyErroraP  Error caused by the response body failing to be parsed.

    This error exists for the quite common situation, where only a partial JSON response is received and
    an attempt to parse the JSON throws an error. In most cases this can be resolved by retrying the
    request. We do that by identifying this error in the HTTPClient.
    c                N    t         |   d       d| _        d| _        || _        y)zCreate the InvalidResponseBodyError instance.

        Args:
            response: The response which failed to be parsed
        z!Response body could not be parsedr+   zinvalid-response-bodyN)r   r   r   coder    )r   r    r"   s     r   r   z!InvalidResponseBodyError.__init__=   s(     	<=.	+	 r   )r   r+   r    r#   r%   r&   r'   r)   s   @r   r+   r+   5   s     
! 
!r   r+   c                    t        | t        t        j                  t        j                  t        j
                  f      ryy)z&Check if the given error is retryable.TF)
isinstancer+   httpxNetworkErrorTimeoutExceptionRemoteProtocolError)es    r   is_retryable_errorr5   K   s/    !.0B0BEDZDZ\a\u\uvwr   )r4   	Exceptionr%   bool)

__future__r   r0   apify_shared.utilsr   r6   r   r   r+   r5   r   r   r   <module>r:      s<    "  *By B"3$ "3T!/ !,r   