a
    }3e6$                     @   sF  d Z ddlZddlZddlmZmZmZmZmZ ddl	m
Z
 ddlmZ zddlZejZW n eyt   d ZZY n0 erddlmZmZmZmZ nd 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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e)Z*G d+d, d,e Z+edurej,fZ-e+ej,fZ.ej/fZ0e+ej/fZ1ne2 Z-e+e)fZ.e2 Z0e+fZ1G d-d. d.ge1R  Z3G d/d0 d0ge.R  Z4dS )1zHTTP related errors.    N)TYPE_CHECKINGAnyOptionalTupleUnion   )RawResponseMessage)LooseHeaders)ClientResponseConnectionKeyFingerprintRequestInfo)ClientErrorClientConnectionErrorClientOSErrorClientConnectorErrorClientProxyConnectionErrorClientSSLErrorClientConnectorSSLErrorClientConnectorCertificateErrorServerConnectionErrorServerTimeoutErrorServerDisconnectedErrorServerFingerprintMismatchClientResponseErrorClientHttpProxyErrorWSServerHandshakeErrorContentTypeErrorClientPayloadError
InvalidURLc                   @   s   e Zd ZdZdS )r   z(Base class for client connection errors.N__name__
__module____qualname____doc__ r%   r%   L/home/pi/bot/my_env/lib/python3.9/site-packages/aiohttp/client_exceptions.pyr   -   s   r   c                	   @   s   e Zd ZdZdddddeeedf ee ee e	ee
 ddddZe	d	d
dZe	d	ddZeed	ddZejeddddZdS )r   zYConnection error during reading response.

    request_info: instance of RequestInfo
    N )codestatusmessageheaders.)request_infohistoryr(   r)   r*   r+   returnc                C   st   || _ |d ur.|d urtdtjdtdd |d ur>|| _n|d urN|| _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   )
r,   
ValueErrorwarningswarnDeprecationWarningr)   r*   r+   r-   args)selfr,   r-   r(   r)   r*   r+   r%   r%   r&   __init__7   s(    
zClientResponseError.__init__r.   c                 C   s   d | j| j| jjS )Nz{}, message={!r}, url={!r})formatr)   r*   r,   Zreal_urlr7   r%   r%   r&   __str__X   s
    zClientResponseError.__str__c                 C   sv   | j d| j}| jdkr,|d| j7 }| jdkrF|d| j7 }| jd ur`|d| j7 }t| j d| dS )	Nz, r   z	, status=r'   z
, message=z
, headers=())r,   r-   r)   r*   r+   typer!   )r7   r6   r%   r%   r&   __repr___   s    


zClientResponseError.__repr__c                 C   s   t jdtdd | jS Nz/code property is deprecated, use status insteadr/   r0   r3   r4   r5   r)   r;   r%   r%   r&   r(   i   s    zClientResponseError.code)valuer.   c                 C   s   t jdtdd || _d S rA   rB   )r7   rC   r%   r%   r&   r(   r   s    )r!   r"   r#   r$   r   r   r
   r   intstrr	   r8   r<   r@   propertyr(   setterr%   r%   r%   r&   r   1   s(   

!
r   c                   @   s   e Zd ZdZdS )r   zContentType found is not valid.Nr    r%   r%   r%   r&   r   |   s   r   c                   @   s   e Zd ZdZdS )r   z!websocket server handshake error.Nr    r%   r%   r%   r&   r      s   r   c                   @   s   e Zd ZdZdS )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      s   r   c                   @   s   e Zd ZdZdS )TooManyRedirectsz%Client was redirected too many times.Nr    r%   r%   r%   r&   rH      s   rH   c                   @   s   e Zd ZdZdS )r   z$Base class for client socket errors.Nr    r%   r%   r%   r&   r      s   r   c                   @   s   e Zd ZdZdS )r   zOSError error.Nr    r%   r%   r%   r&   r      s   r   c                       s   e Zd ZdZeedd fddZeedddZee	dd	d
Z
eee dddZeeededf dddZe	d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.
    N)connection_keyos_errorr.   c                    s,   || _ || _t |j|j ||f| _d S N)	_conn_key	_os_errorsuperr8   errnostrerrorr6   )r7   rI   rJ   	__class__r%   r&   r8      s    zClientConnectorError.__init__r9   c                 C   s   | j S rK   )rM   r;   r%   r%   r&   rJ      s    zClientConnectorError.os_errorc                 C   s   | j jS rK   rL   hostr;   r%   r%   r&   rT      s    zClientConnectorError.hostc                 C   s   | j jS rK   rL   portr;   r%   r%   r&   rV      s    zClientConnectorError.portr   c                 C   s   | j jS rK   )rL   sslr;   r%   r%   r&   rW      s    zClientConnectorError.sslc                 C   s    d | | jd ur| jnd| jS )Nz6Cannot connect to host {0.host}:{0.port} ssl:{1} [{2}]defaultr:   rW   rP   r;   r%   r%   r&   r<      s    zClientConnectorError.__str__)r!   r"   r#   r$   r   OSErrorr8   rF   rJ   rE   rT   r   rD   rV   r   
SSLContextboolrW   r<   BaseException
__reduce____classcell__r%   r%   rQ   r&   r      s   r   c                   @   s   e Zd ZdZdS )r   zProxy connection error.

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

    Raised in :py:class:`aiohttp.connector.UnixConnector`
    if connection to unix socket can not be established.
    N)pathrI   rJ   r.   c                    s   || _ t || d S rK   )_pathrN   r8   )r7   ra   rI   rJ   rQ   r%   r&   r8      s    z!UnixClientConnectorError.__init__r9   c                 C   s   | j S rK   )rb   r;   r%   r%   r&   ra      s    zUnixClientConnectorError.pathc                 C   s    d | | jd ur| jnd| jS )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]rX   rY   r;   r%   r%   r&   r<      s    z UnixClientConnectorError.__str__)r!   r"   r#   r$   rE   r   rZ   r8   rF   ra   r<   r_   r%   r%   rQ   r&   r`      s   r`   c                   @   s   e Zd ZdZdS )r   zServer connection errors.Nr    r%   r%   r%   r&   r      s   r   c                   @   s,   e Zd ZdZdeeedf ddddZdS )r   zServer disconnected.N)r*   r.   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)r6   r*   )r7   r*   r%   r%   r&   r8      s    z ServerDisconnectedError.__init__)N)r!   r"   r#   r$   r   r   rE   r8   r%   r%   r%   r&   r      s   r   c                   @   s   e Zd ZdZdS )r   zServer timeout error.Nr    r%   r%   r%   r&   r      s   r   c                   @   s4   e Zd ZdZeeeeddddZedddZdS )	r   z4SSL certificate does not match expected fingerprint.N)expectedgotrT   rV   r.   c                 C   s*   || _ || _|| _|| _||||f| _d S rK   )rc   rd   rT   rV   r6   )r7   rc   rd   rT   rV   r%   r%   r&   r8      s
    z"ServerFingerprintMismatch.__init__r9   c                 C   s   d | jj| j| j| j| jS )Nz/<{} expected={!r} got={!r} host={!r} port={!r}>)r:   rR   r!   rc   rd   rT   rV   r;   r%   r%   r&   r@      s    z"ServerFingerprintMismatch.__repr__)	r!   r"   r#   r$   bytesrE   rD   r8   r@   r%   r%   r%   r&   r      s   r   c                   @   s   e Zd ZdZdS )r   zResponse payload error.Nr    r%   r%   r%   r&   r     s   r   c                       sH   e Zd ZdZedd fddZeedddZedd	d
Z	  Z
S )r   zbInvalid URL.

    URL used for fetching is malformed, e.g. it doesn't contains host
    part.
    N)urlr.   c                    s   t  | d S rK   )rN   r8   )r7   rf   rQ   r%   r&   r8     s    zInvalidURL.__init__r9   c                 C   s
   | j d S )Nr   )r6   r;   r%   r%   r&   rf     s    zInvalidURL.urlc                 C   s   d| j j d| j dS )N< >)rR   r!   rf   r;   r%   r%   r&   r@     s    zInvalidURL.__repr__)r!   r"   r#   r$   r   r8   rF   rf   rE   r@   r_   r%   r%   rQ   r&   r     s
   r   c                   @   s   e Zd ZdZdS )r   zBase error for ssl.*Errors.Nr    r%   r%   r%   r&   r     s   r   c                   @   s   e Zd ZdZdS )r   zResponse ssl error.Nr    r%   r%   r%   r&   r   3  s   r   c                   @   s|   e Zd ZdZeeddddZeedddZee	dd	d
Z
eee dddZeedddZe	dddZdS )r   zResponse certificate error.N)rI   certificate_errorr.   c                 C   s   || _ || _||f| _d S rK   )rL   _certificate_errorr6   )r7   rI   rj   r%   r%   r&   r8   :  s    z(ClientConnectorCertificateError.__init__r9   c                 C   s   | j S rK   )rk   r;   r%   r%   r&   rj   A  s    z1ClientConnectorCertificateError.certificate_errorc                 C   s   | j jS rK   rS   r;   r%   r%   r&   rT   E  s    z$ClientConnectorCertificateError.hostc                 C   s   | j jS rK   rU   r;   r%   r%   r&   rV   I  s    z$ClientConnectorCertificateError.portc                 C   s   | j jS rK   )rL   Zis_sslr;   r%   r%   r&   rW   M  s    z#ClientConnectorCertificateError.sslc                 C   s
   d | S )Nz{Cannot connect to host {0.host}:{0.port} ssl:{0.ssl} [{0.certificate_error.__class__.__name__}: {0.certificate_error.args}])r:   r;   r%   r%   r&   r<   Q  s    z'ClientConnectorCertificateError.__str__)r!   r"   r#   r$   r   	Exceptionr8   rF   rj   rE   rT   r   rD   rV   r\   rW   r<   r%   r%   r%   r&   r   7  s   r   )5r$   Zasyncior3   typingr   r   r   r   r   Zhttp_parserr   Ztypedefsr	   rW   r[   ImportErrorZclient_reqrepr
   r   r   r   __all__rl   r   r   r   r   r   rH   r   rZ   r   r   r   r`   r   r   TimeoutErrorr   r   r   r2   r   r   CertificateErrorZcert_errorsZcert_errors_basesSSLErrorZ
ssl_errorsZssl_error_basestupler   r   r%   r%   r%   r&   <module>   s^   
K	&
