o
    m=8jY-                     @   s  d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 er(ddl
Z
e
jZnz	ddl
Z
e
jZW n ey>   d Z
ZY nw erTddlmZmZmZmZ ddlmZ nd Z Z ZZ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eZG dd de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%ej'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e-Z.G d4d5 d5e.Z/G d6d7 d7eZ0G d8d9 d9eZ1G d:d; d;e/e0Z2G d<d= d=e1e0Z3G d>d? d?e!Z4e
durUe
j5fZ6e4e
j5fZ7e
j8fZ9e4e
j8fZ:ne; Z6e4e-fZ7e; Z9e4fZ:G d@dA dAge:R  Z<G dBdC dCge7R  Z=G dDdE dEe>Z?dS )FzHTTP related errors.    N)TYPE_CHECKINGUnion)MultiMapping   )StrOrURL)ClientResponseConnectionKeyFingerprintRequestInfo)RawResponseMessage)ClientErrorClientConnectionErrorClientConnectionResetErrorClientOSErrorClientConnectorErrorClientProxyConnectionErrorClientSSLErrorClientConnectorDNSErrorClientConnectorSSLErrorClientConnectorCertificateErrorConnectionTimeoutErrorSocketTimeoutErrorServerConnectionErrorServerTimeoutErrorServerDisconnectedErrorServerFingerprintMismatchClientResponseErrorClientHttpProxyErrorWSServerHandshakeErrorContentTypeErrorClientPayloadError
InvalidURLInvalidUrlClientErrorRedirectClientErrorNonHttpUrlClientErrorInvalidUrlRedirectClientErrorNonHttpUrlRedirectClientErrorWSMessageTypeErrorc                   @      e Zd ZdZdS )r   z(Base class for client connection errors.N__name__
__module____qualname____doc__ r.   r.   `/home/nk/hobo-godmode/plappi-mvp/.venv/lib/python3.10/site-packages/aiohttp/client_exceptions.pyr   =       r   c                   @   s   e Zd ZdZddddddedeedf dedB d	edB d
ede	e dB ddfddZ
defddZdefddZedefddZejdeddfddZdS )r   a  Base class for exceptions that occur after getting a response.

    request_info: An instance of RequestInfo.
    history: A sequence of responses, if redirects occurred.
    status: HTTP status code.
    message: Error message.
    headers: Response headers.
    N )codestatusmessageheadersrequest_infohistory.r2   r3   r4   r5   returnc                C   st   || _ |d ur|d urtdtjdtdd |d ur|| _n|d ur'|| _nd| _|| _|| _|| _||f| _	d S )NzSBoth code and status arguments are provided; code is deprecated, use status insteadz/code argument is deprecated, use status instead   
stacklevelr   )
r6   
ValueErrorwarningswarnDeprecationWarningr3   r4   r5   r7   args)selfr6   r7   r2   r3   r4   r5   r.   r.   r/   __init__K   s(   
zClientResponseError.__init__c                 C   s    | j  d| jdt| jjS )N
, message=z, url=)r3   r4   strr6   real_urlrA   r.   r.   r/   __str__l   s    zClientResponseError.__str__c                 C   sv   | j d| j}| jdkr|d| j7 }| jdkr#|d| j7 }| jd ur0|d| j7 }t| j d| dS )	Nz, r   z	, status=r1   rC   z
, headers=())r6   r7   r3   r4   r5   typer*   )rA   r@   r.   r.   r/   __repr__o   s   


zClientResponseError.__repr__c                 C   s   t jdtdd | jS Nz/code property is deprecated, use status insteadr9   r:   r=   r>   r?   r3   rF   r.   r.   r/   r2   y   s   zClientResponseError.codevaluec                 C   s   t jdtdd || _d S rL   rM   )rA   rN   r.   r.   r/   r2      s   
)r*   r+   r,   r-   r
   tupler   intrD   r   rB   rG   rK   propertyr2   setterr.   r.   r.   r/   r   A   s6    

	
!
r   c                   @   r(   )r   zContentType found is not valid.Nr)   r.   r.   r.   r/   r      r0   r   c                   @   r(   )r   z!websocket server handshake error.Nr)   r.   r.   r.   r/   r      r0   r   c                   @   r(   )r   zHTTP proxy error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
    proxy responds with status other than ``200 OK``
    on ``CONNECT`` request.
    Nr)   r.   r.   r.   r/   r      r0   r   c                   @   r(   )TooManyRedirectsz%Client was redirected too many times.Nr)   r.   r.   r.   r/   rS      r0   rS   c                   @   r(   )r   z$Base class for client socket errors.Nr)   r.   r.   r.   r/   r      r0   r   c                   @   r(   )r   ConnectionResetErrorNr)   r.   r.   r.   r/   r      r0   r   c                   @   r(   )r   zOSError error.Nr)   r.   r.   r.   r/   r      r0   r   c                       s   e Zd ZdZdededdf fddZedefdd	Zede	fd
dZ
ededB fddZedeeedf fddZde	fddZejZ  ZS )r   zClient connector error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        a connection can not be established.
    connection_keyos_errorr8   Nc                    s,   || _ || _t |j|j ||f| _d S N)	_conn_key	_os_errorsuperrB   errnostrerrorr@   )rA   rU   rV   	__class__r.   r/   rB      s   zClientConnectorError.__init__c                 C      | j S rW   )rY   rF   r.   r.   r/   rV         zClientConnectorError.os_errorc                 C      | j jS rW   rX   hostrF   r.   r.   r/   rc         zClientConnectorError.hostc                 C   ra   rW   rX   portrF   r.   r.   r/   rf      rd   zClientConnectorError.portr	   c                 C   ra   rW   )rX   sslrF   r.   r.   r/   rg      rd   zClientConnectorError.sslc                 C   &   d | | jdu rd| jS | j| jS )Nz6Cannot connect to host {0.host}:{0.port} ssl:{1} [{2}]Tdefaultformatrg   r\   rF   r.   r.   r/   rG      
   zClientConnectorError.__str__)r*   r+   r,   r-   r   OSErrorrB   rQ   rV   rD   rc   rP   rf   r   
SSLContextboolrg   rG   BaseException
__reduce____classcell__r.   r.   r]   r/   r      s    r   c                   @   r(   )r   zDNS resolution failed during client connection.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        DNS resolution fails.
    Nr)   r.   r.   r.   r/   r      r0   r   c                   @   r(   )r   zProxy connection error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        connection to proxy can not be established.
    Nr)   r.   r.   r.   r/   r      r0   r   c                       sR   e Zd ZdZdedededdf fddZedefd	d
Z	defddZ
  ZS )UnixClientConnectorErrorzUnix connector error.

    Raised in :py:class:`aiohttp.connector.UnixConnector`
    if connection to unix socket can not be established.
    pathrU   rV   r8   Nc                    s   || _ t || d S rW   )_pathrZ   rB   )rA   rt   rU   rV   r]   r.   r/   rB      s   z!UnixClientConnectorError.__init__c                 C   r_   rW   )ru   rF   r.   r.   r/   rt      r`   zUnixClientConnectorError.pathc                 C   rh   )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]Tri   rj   rF   r.   r.   r/   rG      rl   z UnixClientConnectorError.__str__)r*   r+   r,   r-   rD   r   rm   rB   rQ   rt   rG   rr   r.   r.   r]   r/   rs      s    rs   c                   @   r(   )r   zServer connection errors.Nr)   r.   r.   r.   r/   r      r0   r   c                   @   s,   e Zd ZdZddeeB dB ddfddZdS )r   zServer disconnected.Nr4   r8   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)r@   r4   )rA   r4   r.   r.   r/   rB     s   
z ServerDisconnectedError.__init__rW   )r*   r+   r,   r-   r   rD   rB   r.   r.   r.   r/   r      s     r   c                   @   r(   )r   zServer timeout error.Nr)   r.   r.   r.   r/   r   	  r0   r   c                   @   r(   )r   zConnection timeout error.Nr)   r.   r.   r.   r/   r     r0   r   c                   @   r(   )r   zSocket timeout error.Nr)   r.   r.   r.   r/   r     r0   r   c                
   @   s<   e Zd ZdZdededededdf
dd	Zdefd
dZdS )r   z4SSL certificate does not match expected fingerprint.expectedgotrc   rf   r8   Nc                 C   s*   || _ || _|| _|| _||||f| _d S rW   )rv   rw   rc   rf   r@   )rA   rv   rw   rc   rf   r.   r.   r/   rB     s
   z"ServerFingerprintMismatch.__init__c                 C   s0   d| j j d| jd| jd| jd| jdS )N<z
 expected=z got=z host=z port=>)r^   r*   rv   rw   rc   rf   rF   r.   r.   r/   rK     s   0z"ServerFingerprintMismatch.__repr__)	r*   r+   r,   r-   bytesrD   rP   rB   rK   r.   r.   r.   r/   r     s    r   c                   @   r(   )r    zResponse payload error.Nr)   r.   r.   r.   r/   r    #  r0   r    c                       sp   e Zd ZdZddededB ddf fddZedefdd	ZedddZ	defddZ
defddZ  ZS )r!   zbInvalid URL.

    URL used for fetching is malformed, e.g. it doesn't contains host
    part.
    Nurldescriptionr8   c                    s2   || _ || _|rt || d S t | d S rW   )_url_descriptionrZ   rB   )rA   r{   r|   r]   r.   r/   rB   0  s
   zInvalidURL.__init__c                 C   r_   rW   )r}   rF   r.   r.   r/   r{   ;  r`   zInvalidURL.url
str | Nonec                 C   r_   rW   )r~   rF   r.   r.   r/   r|   ?  r`   zInvalidURL.descriptionc                 C   s   d| j j d|  dS )Nrx    ry   )r^   r*   rF   r.   r.   r/   rK   C  s   zInvalidURL.__repr__c                 C   s"   | j r| j d| j  S t| jS )Nz - )r~   r}   rD   rF   r.   r.   r/   rG   F  s   
zInvalidURL.__str__rW   )r8   r   )r*   r+   r,   r-   r   rD   rB   rQ   r{   r|   rK   rG   rr   r.   r.   r]   r/   r!   '  s     r!   c                   @   r(   )r"   zInvalid URL client error.Nr)   r.   r.   r.   r/   r"   L  r0   r"   c                   @   r(   )r#   zClient redirect error.Nr)   r.   r.   r.   r/   r#   P  r0   r#   c                   @   r(   )r$   zNon http URL client error.Nr)   r.   r.   r.   r/   r$   T  r0   r$   c                   @   r(   )r%   z"Invalid URL redirect client error.Nr)   r.   r.   r.   r/   r%   X  r0   r%   c                   @   r(   )r&   z#Non http URL redirect client error.Nr)   r.   r.   r.   r/   r&   \  r0   r&   c                   @   r(   )r   zBase error for ssl.*Errors.Nr)   r.   r.   r.   r/   r   `  r0   r   c                   @   r(   )r   zResponse ssl error.Nr)   r.   r.   r.   r/   r   x  r0   r   c                       s   e Zd ZU dZeed< dededdf fddZedefd	d
Z	ede
fddZededB fddZedefddZde
fddZ  ZS )r   zResponse certificate error.rX   rU   certificate_errorr8   Nc                    s>   t |ttf r|}nt }t || || _||f| _d S rW   )
isinstancecert_errorsrm   rZ   rB   _certificate_errorr@   )rA   rU   r   rV   r]   r.   r/   rB     s   z(ClientConnectorCertificateError.__init__c                 C   r_   rW   )r   rF   r.   r.   r/   r     r`   z1ClientConnectorCertificateError.certificate_errorc                 C   ra   rW   rb   rF   r.   r.   r/   rc     rd   z$ClientConnectorCertificateError.hostc                 C   ra   rW   re   rF   r.   r.   r/   rf     rd   z$ClientConnectorCertificateError.portc                 C   ra   rW   )rX   is_sslrF   r.   r.   r/   rg     rd   z#ClientConnectorCertificateError.sslc                 C   s4   d| j  d| j d| j d| jjj d| jj dS )NzCannot connect to host :z ssl:z [z: ])rc   rf   rg   r   r^   r*   r@   rF   r.   r.   r/   rG     s   z'ClientConnectorCertificateError.__str__)r*   r+   r,   r-   r   __annotations__	ExceptionrB   rQ   r   rD   rc   rP   rf   ro   rg   rG   rr   r.   r.   r]   r/   r   |  s&   
 r   c                   @   r(   )r'   z$WebSocket message type is not valid.Nr)   r.   r.   r.   r/   r'     r0   r'   )@r-   asyncior=   typingr   r   	multidictr   typedefsr   rg   rn   ImportErrorclient_reqrepr   r   r	   r
   http_parserr   __all__r   r   r   r   r   r   rS   r   rT   r   rm   r   r   r   r   rs   r   r   TimeoutErrorr   r   r   r   r    r<   r!   r"   r#   r$   r%   r&   r   CertificateErrorr   cert_errors_basesSSLError
ssl_errorsssl_error_basesrO   r   r   	TypeErrorr'   r.   r.   r.   r/   <module>   s~    
 K	&%
-