o
     ÞhT  ã                   @   s  d Z ddlmZ dZddl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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 )"z_Errors for the library.

All exceptions defined by the library
should be defined in this file.
é    )Úabsolute_importz$jcgregorio@google.com (Joe Gregorio)N)Ú_helpersc                   @   ó   e Zd ZdZdS )ÚErrorzBase error for this module.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úV/var/www/html/premium_crap/venv/lib/python3.10/site-packages/googleapiclient/errors.pyr      ó    r   c                   @   sD   e Zd ZdZe d¡ddd„ƒZedd„ ƒZdd	„ Z	d
d„ Z
e
ZdS )Ú	HttpErrorz$HTTP data was invalid or unexpected.é   Nc                 C   s8   || _ t|tƒstdƒ‚|| _|| _d| _|  ¡ | _d S )NzHTTP content should be bytesÚ )	ÚrespÚ
isinstanceÚbytesÚ	TypeErrorÚcontentÚuriÚerror_detailsÚ_get_reasonÚreason)Úselfr   r   r   r   r   r   Ú__init__&   s   
zHttpError.__init__c                 C   s   | j jS )z6Return the HTTP status code from the response content.)r   Ústatus©r   r   r   r   Ústatus_code0   s   zHttpError.status_codec              
      s   | j j}zezt | j d¡¡‰ W n tjy    | j d¡‰ Y nw tˆ tƒrBˆ d d }t	‡ fdd„dD ƒdƒ}|rAˆ d | | _
n&tˆ tƒretˆ ƒdkreˆ d }|d d }d	|d v rd|d d	 | _
nˆ | _
W n tttfyu   Y nw |d
u r|d}| ¡ S )z=Calculate the reason for the error from the response content.zutf-8ÚerrorÚmessagec                 3   s    � | ]}|ˆ d  v r|V  qdS )r   Nr   )Ú.0Úkw©Údatar   r   Ú	<genexpr>A   s   € þýz(HttpError._get_reason.<locals>.<genexpr>)ÚdetailÚdetailsÚerrorsr    r   r   r'   N)r   r   ÚjsonÚloadsr   ÚdecodeÚJSONDecodeErrorr   ÚdictÚnextr   ÚlistÚlenÚ
ValueErrorÚKeyErrorr   Ústrip)r   r   Úerror_detail_keywordÚfirst_errorr   r#   r   r   5   s@   þ

þú€€€ÿzHttpError._get_reasonc                 C   sN   | j rd| jj| j| j| j f S | jrd| jj| j| jf S d| jj| jf S )Nz><HttpError %s when requesting %s returned "%s". Details: "%s">z/<HttpError %s when requesting %s returned "%s">z<HttpError %s "%s">)r   r   r   r   r   r   r   r   r   Ú__repr__W   s   üýzHttpError.__repr__©N)r   r   r	   r
   ÚutilÚ
positionalr   Úpropertyr   r   r6   Ú__str__r   r   r   r   r   #   s    	
"r   c                   @   r   )ÚInvalidJsonErrorz&The JSON returned could not be parsed.Nr   r   r   r   r   r<   k   r   r<   c                   @   r   )ÚUnknownFileTypez File type unknown or unexpected.Nr   r   r   r   r   r=   q   r   r=   c                   @   r   )ÚUnknownLinkTypez Link type unknown or unexpected.Nr   r   r   r   r   r>   w   r   r>   c                   @   r   )ÚUnknownApiNameOrVersionz)No API with that name and version exists.Nr   r   r   r   r   r?   }   r   r?   c                   @   r   )ÚUnacceptableMimeTypeErrorz4That is an unacceptable mimetype for this operation.Nr   r   r   r   r   r@   ƒ   r   r@   c                   @   r   )ÚMediaUploadSizeErrorz+Media is larger than the method can accept.Nr   r   r   r   r   rA   ‰   r   rA   c                   @   r   )ÚResumableUploadErrorz'Error occurred during resumable upload.Nr   r   r   r   r   rB   �   r   rB   c                   @   r   )ÚInvalidChunkSizeErrorz!The given chunksize is not valid.Nr   r   r   r   r   rC   •   r   rC   c                   @   r   )ÚInvalidNotificationErrorz$The channel Notification is invalid.Nr   r   r   r   r   rD   ›   r   rD   c                   @   s0   e Zd ZdZe d¡ddd„ƒZdd„ ZeZdS )	Ú
BatchErrorz'Error occurred during batch operations.é   Nc                 C   s   || _ || _|| _d S r7   )r   r   r   )r   r   r   r   r   r   r   r   ¤   s   
zBatchError.__init__c                 C   s.   t | jdd ƒd u rd| j S d| jj| jf S )Nr   z<BatchError "%s">z<BatchError %s "%s">)Úgetattrr   r   r   r   r   r   r   r6   ª   s   
zBatchError.__repr__)NN)	r   r   r	   r
   r8   r9   r   r6   r;   r   r   r   r   rE   ¡   s    rE   c                       s,   e Zd ZdZe d¡d‡ fdd„	ƒZ‡  ZS )ÚUnexpectedMethodErrorz;Exception raised by RequestMockBuilder on unexpected calls.é   Nc                    s   t t| ƒ d| ¡ dS )ú)Constructor for an UnexpectedMethodError.zReceived unexpected call %sN)ÚsuperrH   r   )r   ÚmethodId©Ú	__class__r   r   r   ¶   s   
ÿzUnexpectedMethodError.__init__r7   )r   r   r	   r
   r8   r9   r   Ú__classcell__r   r   rM   r   rH   ³   s    rH   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚUnexpectedBodyErrorz<Exception raised by RequestMockBuilder on unexpected bodies.c                    s   t t| ƒ d||f ¡ dS )rJ   zExpected: [%s] - Provided: [%s]N)rK   rP   r   )r   ÚexpectedÚprovidedrM   r   r   r   Á   s   

ÿzUnexpectedBodyError.__init__)r   r   r	   r
   r   rO   r   r   rM   r   rP   ¾   s    rP   )r
   Ú
__future__r   Ú
__author__r)   Úgoogleapiclientr   r8   Ú	Exceptionr   r   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rH   rP   r   r   r   r   Ú<module>   s&   H