o
    ùT·j™"  ã                   @  s0  d Z ddlmZ ddlZddlZddlmZ ejr!ddlm	Z	m
Z
 g d¢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 d0d1„ d1eƒZ"G d2d3„ d3eƒZ#G d4d5„ d5eƒZ$G d6d7„ d7eƒZ%G d8d9„ d9e&ƒZ'G d:d;„ d;e'ƒZ(G d<d=„ d=e'ƒZ)G d>d?„ d?e'ƒZ*G d@dA„ dAe'ƒZ+ej,dHdIdFdG„ƒZ-dS )Jul  
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
é    )ÚannotationsN)Ú	Generatoré   )ÚRequestÚResponse)Ú
CloseErrorÚConnectErrorÚConnectTimeoutÚCookieConflictÚDecodingErrorÚ	HTTPErrorÚHTTPStatusErrorÚ
InvalidURLÚLocalProtocolErrorÚNetworkErrorÚPoolTimeoutÚProtocolErrorÚ
ProxyErrorÚ	ReadErrorÚReadTimeoutÚRemoteProtocolErrorÚRequestErrorÚRequestNotReadÚResponseNotReadÚStreamClosedÚStreamConsumedÚStreamErrorÚTimeoutExceptionÚTooManyRedirectsÚTransportErrorÚUnsupportedProtocolÚ
WriteErrorÚWriteTimeoutc                   @  ó   e Zd ZdZdS )ÚHTTPXDeprecationWarninga_  A custom deprecation warning for HTTPX.

    Unlike the built-in `DeprecationWarning`, this inherits from `UserWarning` to ensure it is visible by default,
    helping users discover deprecated features without needing to enable warnings explicitly.

    Reference: https://sethmlarson.dev/deprecations-via-warnings-dont-work-for-python-libraries
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r*   r*   úU/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/httpx2/_exceptions.pyr$   K   ó    r$   c                      s@   e Zd ZdZd‡ fdd„Zedd	d
„ƒZejddd
„ƒZ‡  ZS )r   a”  
    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 = httpx2.get("https://www.example.com")
        response.raise_for_status()
    except httpx2.HTTPError as exc:
        print(f"HTTP Exception for {exc.request.url} - {exc}")
    ```
    ÚmessageÚstrÚreturnÚNonec                   s   t ƒ  |¡ d | _d S ©N©ÚsuperÚ__init__Ú_request©Úselfr-   ©Ú	__class__r*   r+   r4   g   s   
zHTTPError.__init__r   c                 C  s   | j d u r	tdƒ‚| j S )Nz'The .request property has not been set.)r5   ÚRuntimeError)r7   r*   r*   r+   Úrequestk   s   
zHTTPError.requestr;   c                 C  s
   || _ d S r1   )r5   )r7   r;   r*   r*   r+   r;   q   s   
©r-   r.   r/   r0   )r/   r   )r;   r   r/   r0   )	r&   r'   r(   r)   r4   Úpropertyr;   ÚsetterÚ__classcell__r*   r*   r8   r+   r   U   s    r   c                      s(   e Zd ZdZddœd‡ fd
d„Z‡  ZS )r   zS
    Base class for all exceptions that may occur when issuing a `.request()`.
    N)r;   r-   r.   r;   úRequest | Noner/   r0   c                  s   t ƒ  |¡ || _d S r1   r2   )r7   r-   r;   r8   r*   r+   r4   {   s   
zRequestError.__init__)r-   r.   r;   r@   r/   r0   ©r&   r'   r(   r)   r4   r?   r*   r*   r8   r+   r   v   s    r   c                   @  r#   )r   zU
    Base class for all exceptions that occur at the level of the Transport API.
    Nr%   r*   r*   r*   r+   r   †   r,   r   c                   @  r#   )r   zM
    The base class for timeout errors.

    An operation has timed out.
    Nr%   r*   r*   r*   r+   r   �   r,   r   c                   @  r#   )r	   z1
    Timed out while connecting to the host.
    Nr%   r*   r*   r*   r+   r	   —   r,   r	   c                   @  r#   )r   z7
    Timed out while receiving data from the host.
    Nr%   r*   r*   r*   r+   r   �   r,   r   c                   @  r#   )r"   z3
    Timed out while sending data to the host.
    Nr%   r*   r*   r*   r+   r"   £   r,   r"   c                   @  r#   )r   zB
    Timed out waiting to acquire a connection from the pool.
    Nr%   r*   r*   r*   r+   r   ©   r,   r   c                   @  r#   )r   zo
    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#   )r   z2
    Failed to receive data from the network.
    Nr%   r*   r*   r*   r+   r   º   r,   r   c                   @  r#   )r!   z2
    Failed to send data through the network.
    Nr%   r*   r*   r*   r+   r!   À   r,   r!   c                   @  r#   )r   z+
    Failed to establish a connection.
    Nr%   r*   r*   r*   r+   r   Æ   r,   r   c                   @  r#   )r   z'
    Failed to close a connection.
    Nr%   r*   r*   r*   r+   r   Ì   r,   r   c                   @  r#   )r   zB
    An error occurred while establishing a proxy connection.
    Nr%   r*   r*   r*   r+   r   Õ   r,   r   c                   @  r#   )r    z€
    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#   )r   z$
    The protocol was violated.
    Nr%   r*   r*   r*   r+   r   ã   r,   r   c                   @  r#   )r   zæ
    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+   r   é   r,   r   c                   @  r#   )r   z^
    The protocol was violated by the server.

    For example, returning malformed HTTP.
    Nr%   r*   r*   r*   r+   r   ó   r,   r   c                   @  r#   )r   zG
    Decoding of the response failed, due to a malformed encoding.
    Nr%   r*   r*   r*   r+   r   þ   r,   r   c                   @  r#   )r   z
    Too many redirects.
    Nr%   r*   r*   r*   r+   r     r,   r   c                      s"   e Zd ZdZd‡ fd
d„Z‡  ZS )r   z|
    The response had an error HTTP status of 4xx or 5xx.

    May be raised when calling `response.raise_for_status()`
    r-   r.   r;   r   Úresponser   r/   r0   c                  s   t ƒ  |¡ || _|| _d S r1   )r3   r4   r;   rB   )r7   r-   r;   rB   r8   r*   r+   r4     s   
zHTTPStatusError.__init__)r-   r.   r;   r   rB   r   r/   r0   rA   r*   r*   r8   r+   r     ó    r   c                      ó"   e Zd ZdZd‡ fdd„Z‡  ZS )	r   z7
    URL is improperly formed or cannot be parsed.
    r-   r.   r/   r0   c                   ó   t ƒ  |¡ d S r1   ©r3   r4   r6   r8   r*   r+   r4     ó   zInvalidURL.__init__r<   rA   r*   r*   r8   r+   r     ó    r   c                      rD   )	r
   z†
    Attempted to lookup a cookie by name, but multiple cookies existed.

    Can occur when calling `response.cookies.get(...)`.
    r-   r.   r/   r0   c                   rE   r1   rF   r6   r8   r*   r+   r4   *  rG   zCookieConflict.__init__r<   rA   r*   r*   r8   r+   r
   #  rC   r
   c                      rD   )	r   z‡
    The base class for stream exceptions.

    The developer made an error in accessing the request stream in
    an invalid way.
    r-   r.   r/   r0   c                   rE   r1   rF   r6   r8   r*   r+   r4   <  rG   zStreamError.__init__r<   rA   r*   r*   r8   r+   r   4  s    r   c                      ó"   e Zd ZdZd‡ fdd„Z‡  ZS )r   z]
    Attempted to read or stream content, but the content has already
    been streamed.
    r/   r0   c                   ó   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.rF   r6   r8   r*   r+   r4   F  s   ÿzStreamConsumed.__init__©r/   r0   rA   r*   r*   r8   r+   r   @  ó    r   c                      rI   )r   z\
    Attempted to read or stream response content, but the request has been
    closed.
    r/   r0   c                   rJ   )NzDAttempted to read or stream content, but the stream has been closed.rF   r6   r8   r*   r+   r4   X  ó   zStreamClosed.__init__rK   rA   r*   r*   r8   r+   r   R  rL   r   c                      rI   )r   zY
    Attempted to access streaming response content, without having called `read()`.
    r/   r0   c                   rJ   )NzOAttempted to access streaming response content, without having called `read()`.rF   r6   r8   r*   r+   r4   b  rM   zResponseNotRead.__init__rK   rA   r*   r*   r8   r+   r   ]  rH   r   c                      rI   )r   zX
    Attempted to access streaming request content, without having called `read()`.
    r/   r0   c                   rJ   )NzNAttempted to access streaming request content, without having called `read()`.rF   r6   r8   r*   r+   r4   l  rM   zRequestNotRead.__init__rK   rA   r*   r*   r8   r+   r   g  rH   r   r;   r@   r/   úGenerator[None]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_contextq  s   €€ýrP   r1   )r;   r@   r/   rN   ).r)   Ú
__future__r   Ú
contextlibÚtypingÚcollections.abcr   ÚTYPE_CHECKINGÚ_modelsr   r   Ú__all__ÚUserWarningr$   Ú	Exceptionr   r   r   r   r	   r   r"   r   r   r   r!   r   r   r   r    r   r   r   r   r   r   r   r
   r:   r   r   r   r   r   ÚcontextmanagerrP   r*   r*   r*   r+   Ú<module>   sN    ! 
!			
		

