o
    h                     @   s  d Z ddlZddlZejrddlmZmZ G dd deZG dd deZ	G d	d
 d
e	Z
G dd de
ZG dd deZG dd deZG dd deZG dd deZG dd de
ZG dd deZG dd deZG dd deZG dd deZG dd  d e
ZG d!d" d"e
ZG d#d$ d$e
ZG d%d& d&eZG d'd( d(eZG d)d* d*e	ZG d+d, d,e	ZG d-d. d.eZG d/d0 d0eZG d1d2 d2eZG d3d4 d4eZ G d5d6 d6e Z!G d7d8 d8e Z"G d9d: d:e Z#G d;d< d<e Z$ej%	dBd=ej&d> d?ej'd fd@dAZ(dS )Cul  
Our exception hierarchy:

* HTTPError
  x RequestError
    + TransportError
      - TimeoutException
        · ConnectTimeout
        · ReadTimeout
        · WriteTimeout
        · PoolTimeout
      - NetworkError
        · ConnectError
        · ReadError
        · WriteError
        · CloseError
      - ProtocolError
        · LocalProtocolError
        · RemoteProtocolError
      - ProxyError
      - UnsupportedProtocol
    + DecodingError
    + TooManyRedirects
  x HTTPStatusError
* InvalidURL
* CookieConflict
* StreamError
  x StreamConsumed
  x StreamClosed
  x ResponseNotRead
  x RequestNotRead
    N   )RequestResponsec                       sH   e Zd ZdZdeddf fddZeddd	Zejddd	Z  Z	S )	HTTPErrora  
    Base class for `RequestError` and `HTTPStatusError`.

    Useful for `try...except` blocks when issuing a request,
    and then calling `.raise_for_status()`.

    For example:

    ```
    try:
        response = httpx.get("https://www.example.com")
        response.raise_for_status()
    except httpx.HTTPError as exc:
        print(f"HTTP Exception for {exc.request.url} - {exc}")
    ```
    messagereturnNc                    s   t  | d | _d S Nsuper__init___requestselfr   	__class__ G/var/www/html/ai/venv/lib/python3.10/site-packages/httpx/_exceptions.pyr   :   s   
zHTTPError.__init__r   c                 C   s   | j d u r	td| j S )Nz'The .request property has not been set.)r   RuntimeError)r   r   r   r   request>   s   
zHTTPError.requestr   c                 C   s
   || _ d S r   )r   )r   r   r   r   r   r   D   s   
)r   r   )r   r   r   N)
__name__
__module____qualname____doc__strr   propertyr   setter__classcell__r   r   r   r   r   (   s    r   c                       s:   e Zd ZdZdddedejd ddf fdd	Z  ZS )
RequestErrorzS
    Base class for all exceptions that may occur when issuing a `.request()`.
    N)r   r   r   r   r   c                   s   t  | || _d S r   r	   )r   r   r   r   r   r   r   N   s   
zRequestError.__init__)	r   r   r   r   r   typingOptionalr   r   r   r   r   r   r   I   s    r   c                   @      e Zd ZdZdS )TransportErrorzU
    Base class for all exceptions that occur at the level of the Transport API.
    Nr   r   r   r   r   r   r   r   r!   [       r!   c                   @   r    )TimeoutExceptionzM
    The base class for timeout errors.

    An operation has timed out.
    Nr"   r   r   r   r   r$   d   r#   r$   c                   @   r    )ConnectTimeoutz1
    Timed out while connecting to the host.
    Nr"   r   r   r   r   r%   l   r#   r%   c                   @   r    )ReadTimeoutz7
    Timed out while receiving data from the host.
    Nr"   r   r   r   r   r&   r   r#   r&   c                   @   r    )WriteTimeoutz3
    Timed out while sending data to the host.
    Nr"   r   r   r   r   r'   x   r#   r'   c                   @   r    )PoolTimeoutzB
    Timed out waiting to acquire a connection from the pool.
    Nr"   r   r   r   r   r(   ~   r#   r(   c                   @   r    )NetworkErrorzo
    The base class for network-related errors.

    An error occurred while interacting with the network.
    Nr"   r   r   r   r   r)      r#   r)   c                   @   r    )	ReadErrorz2
    Failed to receive data from the network.
    Nr"   r   r   r   r   r*      r#   r*   c                   @   r    )
WriteErrorz2
    Failed to send data through the network.
    Nr"   r   r   r   r   r+      r#   r+   c                   @   r    )ConnectErrorz+
    Failed to establish a connection.
    Nr"   r   r   r   r   r,      r#   r,   c                   @   r    )
CloseErrorz'
    Failed to close a connection.
    Nr"   r   r   r   r   r-      r#   r-   c                   @   r    )
ProxyErrorzB
    An error occurred while establishing a proxy connection.
    Nr"   r   r   r   r   r.      r#   r.   c                   @   r    )UnsupportedProtocolz
    Attempted to make a request to an unsupported protocol.

    For example issuing a request to `ftp://www.example.com`.
    Nr"   r   r   r   r   r/      r#   r/   c                   @   r    )ProtocolErrorz$
    The protocol was violated.
    Nr"   r   r   r   r   r0      r#   r0   c                   @   r    )LocalProtocolErrorz
    A protocol was violated by the client.

    For example if the user instantiated a `Request` instance explicitly,
    failed to include the mandatory `Host:` header, and then issued it directly
    using `client.send()`.
    Nr"   r   r   r   r   r1      r#   r1   c                   @   r    )RemoteProtocolErrorz^
    The protocol was violated by the server.

    For example, returning malformed HTTP.
    Nr"   r   r   r   r   r2      r#   r2   c                   @   r    )DecodingErrorzG
    Decoding of the response failed, due to a malformed encoding.
    Nr"   r   r   r   r   r3      r#   r3   c                   @   r    )TooManyRedirectsz
    Too many redirects.
    Nr"   r   r   r   r   r4      r#   r4   c                       s2   e Zd ZdZdeddddddf fd	d
Z  ZS )HTTPStatusErrorz|
    The response had an error HTTP status of 4xx or 5xx.

    May be raised when calling `response.raise_for_status()`
    r   r   r   responser   r   Nc                   s   t  | || _|| _d S r   )r
   r   r   r6   )r   r   r   r6   r   r   r   r      s   
zHTTPStatusError.__init__r   r   r   r   r   r   r   r   r   r   r   r5      s    r5   c                       *   e Zd ZdZdeddf fddZ  ZS )
InvalidURLz7
    URL is improperly formed or cannot be parsed.
    r   r   Nc                       t  | d S r   r
   r   r   r   r   r   r         zInvalidURL.__init__r7   r   r   r   r   r9      s    r9   c                       r8   )CookieConflictz
    Attempted to lookup a cookie by name, but multiple cookies existed.

    Can occur when calling `response.cookies.get(...)`.
    r   r   Nc                    r:   r   r;   r   r   r   r   r     r<   zCookieConflict.__init__r7   r   r   r   r   r=      s    r=   c                       r8   )StreamErrorz
    The base class for stream exceptions.

    The developer made an error in accessing the request stream in
    an invalid way.
    r   r   Nc                    r:   r   r;   r   r   r   r   r     r<   zStreamError.__init__r7   r   r   r   r   r>     s    r>   c                       "   e Zd ZdZd fddZ  ZS )StreamConsumedz]
    Attempted to read or stream content, but the content has already
    been streamed.
    r   Nc                       d}t  | d S )Na]  Attempted to read or stream some content, but the content has already been streamed. For requests, this could be due to passing a generator as request content, and then receiving a redirect response or a secondary request as part of an authentication flow.For responses, this could be due to attempting to stream the response content more than once.r;   r   r   r   r   r     s   zStreamConsumed.__init__r   Nr   r   r   r   r   r   r   r   r   r   r@         r@   c                       r?   )StreamClosedz\
    Attempted to read or stream response content, but the request has been
    closed.
    r   Nc                    rA   )NzDAttempted to read or stream content, but the stream has been closed.r;   r   r   r   r   r   /  s   zStreamClosed.__init__rB   rC   r   r   r   r   rE   )  rD   rE   c                       r?   )ResponseNotReadzY
    Attempted to access streaming response content, without having called `read()`.
    r   Nc                    rA   )NzOAttempted to access streaming response content, without having called `read()`.r;   r   r   r   r   r   ;     zResponseNotRead.__init__rB   rC   r   r   r   r   rF   6      rF   c                       r?   )RequestNotReadzX
    Attempted to access streaming request content, without having called `read()`.
    r   Nc                    rA   )NzNAttempted to access streaming request content, without having called `read()`.r;   r   r   r   r   r   E  rG   zRequestNotRead.__init__rB   rC   r   r   r   r   rI   @  rH   rI   r   r   r   c              
   c   s:    zdV  W dS  t y } z	| dur| |_|d}~ww )z
    A context manager that can be used to attach the given request context
    to any `RequestError` exceptions that are raised within the block.
    N)r   r   )r   excr   r   r   request_contextJ  s   rK   r   ))r   
contextlibr   TYPE_CHECKING_modelsr   r   	Exceptionr   r   r!   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r9   r=   r   r>   r@   rE   rF   rI   contextmanagerr   IteratorrK   r   r   r   r   <module>   sP     !			
		

