o
    eZh                     @   s   d dl mZmZ ddl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dS )    )AnyTuple   )ApiResponseMetac                   @      e Zd ZdZdS )TransportWarningz4Generic warning for the 'elastic-transport' package.N__name__
__module____qualname____doc__ r   r   T/var/www/html/lang_env/lib/python3.10/site-packages/elastic_transport/_exceptions.pyr          r   c                   @   r   )SecurityWarningz0Warning for potentially insecure configurations.Nr   r   r   r   r   r      r   r   c                       sP   e Zd ZdZddedeedf f fddZdefd	d
Z	defddZ
  ZS )TransportErrora[  Generic exception for the 'elastic-transport' package.

    For the 'errors' attribute, errors are ordered from
    most recently raised (index=0) to least recently raised (index=N)

    If an HTTP status code is available with the error it
    will be stored under 'status'. If HTTP headers are available
    they are stored under 'headers'.
    r   messageerrors.c                    s    t  | t|| _|| _d S N)super__init__tupler   r   )selfr   r   	__class__r   r   r   *   s   

zTransportError.__init__returnc                 C   s:   t | jg}| jr|d| j d| jjd|S )Nerrors={}({}), )reprr   r   appendformatr   r	   joinr   partsr   r   r   __repr__/   s   zTransportError.__repr__c                 C   s
   t | jS r   )strr   r   r   r   r   __str__5   s   
zTransportError.__str__r   )r	   r
   r   r   r   r   	Exceptionr   r&   r%   r(   __classcell__r   r   r   r   r      s
     
r   c                   @   r   )SniffingErrorz.Error that occurs during the sniffing of nodesNr   r   r   r   r   r,   9   r   r,   c                   @   r   )SerializationErrorz`Error that occurred during the serialization or
    deserialization of an HTTP message body
    Nr   r   r   r   r   r-   =   r   r-   c                   @      e Zd ZdZdefddZdS )ConnectionErrorz#Error raised by the HTTP connectionr   c                 C   ,   | j rd| j d jj d| j d  dS dS )NzConnection error caused by: r   ()zConnection errorr   r   r	   r'   r   r   r   r(   F      "zConnectionError.__str__Nr	   r
   r   r   r&   r(   r   r   r   r   r/   C       r/   c                   @   r.   )TlsErrorz(Error raised by during the TLS handshaker   c                 C   r0   )NzTLS error caused by: r   r1   r2   z	TLS errorr3   r'   r   r   r   r(   O   r4   zTlsError.__str__Nr5   r   r   r   r   r7   L   r6   r7   c                   @   r.   )ConnectionTimeoutz(Connection timed out during an operationr   c                 C   r0   )NzConnection timeout caused by: r   r1   r2   zConnection timed outr3   r'   r   r   r   r(   X   r4   zConnectionTimeout.__str__Nr5   r   r   r   r   r8   U   r6   r8   c                       sZ   e Zd ZdZ	ddedededeedf f fdd	Z	d
efddZ
d
efddZ  ZS )ApiErrorzRBase-class for clients that raise errors due to a response such as '404 Not Found'r   r   metabodyr   .c                    s(   t  | || _|| _|| _|| _d S r   )r   r   r   r   r:   r;   )r   r   r:   r;   r   r   r   r   r   a   s
   
zApiError.__init__r   c                 C   sn   t | jg}| jr|d| j | jr|d| j | jd ur,|d| j d| jjd	|S )Nzmeta=r   zbody=r   r   )
r   r   r:   r    r   r;   r!   r   r	   r"   r#   r   r   r   r%   n   s   
zApiError.__repr__c                 C   s   d| j j d| j S )N[z] )r:   statusr   r'   r   r   r   r(   x   s   zApiError.__str__r)   )r	   r
   r   r   r&   r   r   r   r*   r   r%   r(   r+   r   r   r   r   r9   ^   s    

r9   N)typingr   r   Z_modelsr   Warningr   r   r*   r   r,   r-   r/   r7   r8   r9   r   r   r   r   <module>   s   			