
    rhT                     `   d Z ddlmZ dZddlZddlmZ  G d de      Z	 G d d	e	      Z
 G d
 de	      Z G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de	      Z G d de
      Z G d de	      Z G d de	      Z G d de
      Z G d de	      Z G d  d!e	      Zy)"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y)ErrorzBase error for this module.N__name__
__module____qualname____doc__     i/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/googleapiclient/errors.pyr   r      s    %r   r   c                   b    e Zd ZdZ ej
                  d      dd       Zed        Zd Z	d Z
e
Zy)		HttpErrorz$HTTP data was invalid or unexpected.   Nc                     || _         t        |t              st        d      || _        || _        d| _        | j                         | _        y )NzHTTP content should be bytes )	resp
isinstancebytes	TypeErrorcontenturierror_details_get_reasonreason)selfr   r   r   s       r   __init__zHttpError.__init__&   sE    	'5):;;&&(r   c                 .    | j                   j                  S )z6Return the HTTP status code from the response content.)r   statusr   s    r   status_codezHttpError.status_code0   s     yyr   c                 \   | j                   j                  }	 	 t        j                  | j                  j                  d            t        t              r-d   d   }t        fddD        d      }|rUd   |   | _
        nGt        t              r0t              dkD  r"d   }|d   d   }d|d   v r|d   d   | _
        n| _
        |d}|j!                         S # t        j                  $ r | j                  j                  d      Y w xY w# t        t        t        f$ r Y ^w xY w)	z=Calculate the reason for the error from the response content.zutf-8errormessagec              3   0   K   | ]  }|d    v r|  yw)r$   Nr   ).0kwdatas     r   	<genexpr>z(HttpError._get_reason.<locals>.<genexpr>A   s%      g. s   )detaildetailserrorsr%   r   r   r,   )r   r   jsonloadsr   decodeJSONDecodeErrorr   dictnextr   listlen
ValueErrorKeyErrorr   strip)r   r   error_detail_keywordfirst_errorr)   s       @r   r   zHttpError._get_reason5   s7   !!	4zz$,,"5"5g">? $%gy1'+"L
 ($ ()-g7K)LD&D$'CIM"1g$W-i8G 44)4W)=i)HD&%)" >F||~5 '' 4||**734, Hi0 		s0   .C  BD  .DD DD D+*D+c           	      j   | j                   rAd| j                  j                  d| j                  d| j                  d| j                   d	S | j                  r4d| j                  j                  d| j                  d| j                  dS d| j                  j                  d| j                  dS )Nz<HttpError z when requesting z returned "z". Details: ""> ")r   r   r    r   r   r!   s    r   __repr__zHttpError.__repr__W   s    		  ""	  XX		     -1II,<,<dkkJJr   N)r   r	   r
   r   util
positionalr   propertyr"   r   r>   __str__r   r   r   r   r   #   sI    .T__Q) )     DK" Gr   r   c                       e Zd ZdZy)InvalidJsonErrorz&The JSON returned could not be parsed.Nr   r   r   r   rE   rE   k   s    0r   rE   c                       e Zd ZdZy)UnknownFileTypez File type unknown or unexpected.Nr   r   r   r   rG   rG   q       *r   rG   c                       e Zd ZdZy)UnknownLinkTypez Link type unknown or unexpected.Nr   r   r   r   rJ   rJ   w   rH   r   rJ   c                       e Zd ZdZy)UnknownApiNameOrVersionz)No API with that name and version exists.Nr   r   r   r   rL   rL   }   s    3r   rL   c                       e Zd ZdZy)UnacceptableMimeTypeErrorz4That is an unacceptable mimetype for this operation.Nr   r   r   r   rN   rN      s    >r   rN   c                       e Zd ZdZy)MediaUploadSizeErrorz+Media is larger than the method can accept.Nr   r   r   r   rP   rP      s    5r   rP   c                       e Zd ZdZy)ResumableUploadErrorz'Error occurred during resumable upload.Nr   r   r   r   rR   rR      s    1r   rR   c                       e Zd ZdZy)InvalidChunkSizeErrorz!The given chunksize is not valid.Nr   r   r   r   rT   rT      s    +r   rT   c                       e Zd ZdZy)InvalidNotificationErrorz$The channel Notification is invalid.Nr   r   r   r   rV   rV      s    .r   rV   c                   L    e Zd ZdZ ej
                  d      dd       Zd ZeZy)
BatchErrorz'Error occurred during batch operations.   Nc                 .    || _         || _        || _        y r?   )r   r   r   )r   r   r   r   s       r   r   zBatchError.__init__   s    	r   c                     t        | j                  dd       d| j                  z  S d| j                  j                  d| j                  dS )Nr    z<BatchError "%s">z<BatchError r=   r<   )getattrr   r   r    r!   s    r   r>   zBatchError.__repr__   sD    499h-5&$++66 6 .2YY-=-=t{{KKr   )NN)	r   r	   r
   r   r@   rA   r   r>   rC   r   r   r   rX   rX      s/    1T__Q 
L Gr   rX   c                   N     e Zd ZdZ ej
                  d      d fd	       Z xZS )UnexpectedMethodErrorz;Exception raised by RequestMockBuilder on unexpected calls.   c                 2    t         t        |   d|z         y))Constructor for an UnexpectedMethodError.zReceived unexpected call %sN)superr^   r   )r   methodId	__class__s     r   r   zUnexpectedMethodError.__init__   s     	#T3)H4	
r   r?   )r   r	   r
   r   r@   rA   r   __classcell__rd   s   @r   r^   r^      s#    ET__Q
 
r   r^   c                   "     e Zd ZdZ fdZ xZS )UnexpectedBodyErrorz<Exception raised by RequestMockBuilder on unexpected bodies.c                 :    t         t        |   d|d|d       y)ra   zExpected: [z] - Provided: []N)rb   rh   r   )r   expectedprovidedrd   s      r   r   zUnexpectedBodyError.__init__   s    !41198D	
r   )r   r	   r
   r   r   re   rf   s   @r   rh   rh      s    F
 
r   rh   )r   
__future__r   
__author__r.   googleapiclientr   r@   	Exceptionr   r   rE   rG   rJ   rL   rN   rP   rR   rT   rV   rX   r^   rh   r   r   r   <module>rq      s   
 '3
  ,	I 	E EP	u 		e 		e 		e 		 		5 		9 		E 		u 	 $
E 

% 
r   