U
    Ê¼µb  ã                   @   s  d Z ddl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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dS )!z@
h2/exceptions
~~~~~~~~~~~~~

Exceptions for the HTTP/2 module.
é    Nc                   @   s   e Zd ZdZdS )ÚH2ErrorzB
    The base class for all exceptions for the HTTP/2 module.
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú1/tmp/pip-unpacked-wheel-n0jtiqmd/h2/exceptions.pyr      s   r   c                   @   s   e Zd ZdZejjjZdS )ÚProtocolErrorzF
    An action was attempted in violation of the HTTP/2 protocol.
    N)	r   r   r   r   Úh2ÚerrorsÚ
ErrorCodesZPROTOCOL_ERRORÚ
error_coder   r   r   r	   r
      s   r
   c                   @   s   e Zd ZdZejjjZdS )ÚFrameTooLargeErrorzL
    The frame that we tried to send or that we received was too large.
    N©	r   r   r   r   r   r   r   ZFRAME_SIZE_ERRORr   r   r   r   r	   r      s   r   c                   @   s   e Zd ZdZejjjZdS )ÚFrameDataMissingErrorzW
    The frame that we received is missing some data.

    .. versionadded:: 2.0.0
    Nr   r   r   r   r	   r   !   s   r   c                   @   s   e Zd ZdZdS )ÚTooManyStreamsErrorzb
    An attempt was made to open a stream that would lead to too many concurrent
    streams.
    Nr   r   r   r   r	   r   +   s   r   c                   @   s   e Zd ZdZejjjZdS )ÚFlowControlErrorz@
    An attempted action violates flow control constraints.
    N)	r   r   r   r   r   r   r   ZFLOW_CONTROL_ERRORr   r   r   r   r	   r   3   s   r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚStreamIDTooLowErrorz„
    An attempt was made to open a stream that had an ID that is lower than the
    highest ID we have seen on this connection.
    c                 C   s   || _ || _d S ©N©Ú	stream_idÚmax_stream_id)Úselfr   r   r   r   r	   Ú__init__A   s    zStreamIDTooLowError.__init__c                 C   s   d| j | jf S )Nz(StreamIDTooLowError: %d is lower than %dr   ©r   r   r   r	   Ú__str__H   s     ÿzStreamIDTooLowError.__str__N©r   r   r   r   r   r   r   r   r   r	   r   <   s   r   c                   @   s   e Zd ZdZdS )ÚNoAvailableStreamIDErrorzˆ
    There are no available stream IDs left to the connection. All stream IDs
    have been exhausted.

    .. versionadded:: 2.0.0
    Nr   r   r   r   r	   r   N   s   r   c                   @   s   e Zd ZdZdd„ ZdS )ÚNoSuchStreamErrorzÂ
    A stream-specific action referenced a stream that does not exist.

    .. versionchanged:: 2.0.0
       Became a subclass of :class:`ProtocolError
       <h2.exceptions.ProtocolError>`
    c                 C   s
   || _ d S r   )r   ©r   r   r   r   r	   r   `   s    zNoSuchStreamError.__init__N©r   r   r   r   r   r   r   r   r	   r   X   s   r   c                   @   s   e Zd ZdZdd„ ZdS )ÚStreamClosedErrorzÙ
    A more specific form of
    :class:`NoSuchStreamError <h2.exceptions.NoSuchStreamError>`. Indicates
    that the stream has since been closed, and that all state relating to that
    stream has been removed.
    c                 C   s   || _ tjjj| _g | _d S r   )r   r   r   r   ZSTREAM_CLOSEDr   Z_eventsr    r   r   r	   r   l   s    zStreamClosedError.__init__Nr!   r   r   r   r	   r"   e   s   r"   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚInvalidSettingsValueErrorz\
    An attempt was made to set an invalid Settings value.

    .. versionadded:: 2.0.0
    c                    s   t t| ƒ |¡ || _d S r   )Úsuperr#   r   r   )r   Úmsgr   ©Ú	__class__r   r	   r   ~   s    z"InvalidSettingsValueError.__init__)r   r   r   r   r   Ú__classcell__r   r   r&   r	   r#   x   s   r#   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚInvalidBodyLengthErrorz{
    The remote peer sent more or less data that the Content-Length header
    indicated.

    .. versionadded:: 2.0.0
    c                 C   s   || _ || _d S r   ©Zexpected_lengthZactual_length)r   ÚexpectedÚactualr   r   r	   r   Š   s    zInvalidBodyLengthError.__init__c                 C   s   d| j | jf S )Nz6InvalidBodyLengthError: Expected %d bytes, received %dr*   r   r   r   r	   r   Ž   s     ÿzInvalidBodyLengthError.__str__Nr   r   r   r   r	   r)   ƒ   s   r)   c                   @   s   e Zd ZdZdS )ÚUnsupportedFrameErrorzh
    The remote peer sent a frame that is unsupported in this context.

    .. versionadded:: 2.1.0
    Nr   r   r   r   r	   r-   ”   s   r-   c                   @   s   e Zd ZdZdS )ÚRFC1122Errora—  
    Emitted when users attempt to do something that is literally allowed by the
    relevant RFC, but is sufficiently ill-defined that it's unwise to allow
    users to actually do it.

    While there is some disagreement about whether or not we should be liberal
    in what accept, it is a truth universally acknowledged that we should be
    conservative in what emit.

    .. versionadded:: 2.4.0
    Nr   r   r   r   r	   r.   ž   s   r.   c                   @   s   e Zd ZdZejjjZdS )ÚDenialOfServiceErrora@  
    Emitted when the remote peer exhibits a behaviour that is likely to be an
    attempt to perform a Denial of Service attack on the implementation. This
    is a form of ProtocolError that carries a different error code, and allows
    more easy detection of this kind of behaviour.

    .. versionadded:: 2.5.0
    N)	r   r   r   r   r   r   r   ZENHANCE_YOUR_CALMr   r   r   r   r	   r/   ¯   s   
r/   )r   Z	h2.errorsr   Ú	Exceptionr   r
   r   r   r   r   r   r   r   r"   Ú
ValueErrorr#   r)   ÚKeyErrorr-   r.   r/   r   r   r   r	   Ú<module>   s    
	

