o
    3O                     @   s   d Z e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dd Zd S )!zlazr.restfulclient errors.)
BadRequestConflictClientErrorCredentialsErrorCredentialsFileError	HTTPErrorMethodNotAllowedNotFoundPreconditionFailedRestfulErrorResponseErrorServerErrorUnauthorizedUnexpectedResponseErrorc                   @      e Zd ZdZdS )r
   z2Base error for the lazr.restfulclient API library.N__name__
__module____qualname____doc__ r   r   ;/usr/lib/python3/dist-packages/lazr/restfulclient/errors.pyr
   (       r
   c                   @   r   )r   z&Base credentials/authentication error.Nr   r   r   r   r   r   ,   r   r   c                   @   r   )r   zError in credentials file.Nr   r   r   r   r   r   0   r   r   c                   @      e Zd ZdZdd ZdS )r   zError in response.c                 C   s   t |  || _|| _d S )N)r
   __init__responsecontent)selfr   r   r   r   r   r   7   s   

zResponseError.__init__N)r   r   r   r   r   r   r   r   r   r   4       r   c                   @   r   )r   z$An unexpected response was received.c                 C   s   d| j j| j jf S )N%s: %s)r   statusreason)r   r   r   r   __str__@   s   zUnexpectedResponseError.__str__Nr   r   r   r   r!   r   r   r   r   r   =   r   r   c                   @   r   )r   z+An HTTP non-2xx response code was received.c                 C   s8   d dd t| j D }d| jj| jj|| jf S )z9Show the error code, response headers, and response body.
c                 S   s   g | ]}d | qS )r   r   ).0pairr   r   r   
<listcomp>I   s    z%HTTPError.__str__.<locals>.<listcomp>zIHTTP Error %s: %s
Response headers:
---
%s
---
Response body:
---
%s
---
)joinsortedr   itemsr   r    r   )r   headersr   r   r   r!   G   s   
zHTTPError.__str__Nr"   r   r   r   r   r   D   r   r   c                   @   r   )r   z.An exception representing a client-side error.Nr   r   r   r   r   r   Q   r   r   c                   @   r   )r   z4An exception representing an authentication failure.Nr   r   r   r   r   r   U   r   r   c                   @   r   )r   z1An exception representing a nonexistent resource.Nr   r   r   r   r   r   Y   r   r   c                   @   r   )r   zAn exception raised when you use an unsupported HTTP method.

    This is most likely because you tried to delete a resource that
    can't be deleted.
    Nr   r   r   r   r   r   ]   r   r   c                   @   r   )r   z:An exception representing a problem with a client request.Nr   r   r   r   r   r   e   r   r   c                   @   r   )r   z9An exception representing a conflict with another client.Nr   r   r   r   r   r   i   r   r   c                   @   r   )r	   zAn exception representing the failure of a conditional PUT/PATCH.

    The most likely explanation is that another client changed this
    object while you were working on it, and your version of the
    object is now out of date.
    Nr   r   r   r   r   r	   m   r   r	   c                   @   r   )r   z.An exception representing a server-side error.Nr   r   r   r   r   r   u   r   r   c                 C   sj   t tttttd}| jd dkrdS || jt}|tu r0| jd dkr't	}n	| jd dkr0t
}|| |S )zTurn an HTTP response into an HTTPError subclass.

    :return: None if the response code is 1xx, 2xx or 3xx. Otherwise,
    an instance of an appropriate HTTPError subclass (or HTTPError
    if nothing else is appropriate.
    )i  i  i  i  i  i  d      N      )r   r   r   r   r   r	   r   getr   r   r   )r   r   http_errors_by_status_codeclsr   r   r   	error_fory   s    	
r2   N)r   type__metaclass____all__	Exceptionr
   r   r   r   r   r   r   r   r   r   r   r   r	   r   r2   r   r   r   r   <module>   s$   	