
    '                     d   d Z ddlmZ ddl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_importN)_helpersc                       e Zd ZdZy)ErrorzBase error for this module.N__name__
__module____qualname____doc__     1platform/bq/third_party/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        j                  |      }|| _        || _        d| _        | j                          y # t        $ r t        d      w xY w)NzHTTP content should be bytes )respsixensure_binary	TypeErrorcontenturierror_details_get_reason)selfr   r   r   s       r   __init__zHttpError.__init__(   s_    		<''0G   	<:;;	<s   A Ac                 .    | j                   j                  S )z6Return the HTTP status code from the response content.)r   statusr   s    r   status_codezHttpError.status_code4   s     yyr   c                 p   t        | j                  d      r| j                  j                  nd}	 	 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}|S # t        j                  $ r | j
                  j                  d      Y w xY w# t        t        t         f$ r Y Pw xY w)z=Calculate the reason for the error from the response content.reasonNzutf-8errormessagec              3   2   K   | ]  }|d    v s|  yw)r$   Nr   ).0kwdatas     r   	<genexpr>z(HttpError._get_reason.<locals>.<genexpr>D   s#     ,|:dBhjnrszn{h{R:ds   )detaildetailserrorsr%   r   r   r,   )hasattrr   r#   jsonloadsr   decodeJSONDecodeError
isinstancedictnextr   listlen
ValueErrorKeyErrorr   )r   r#   error_detail_keywordfirst_errorr)   s       @r   r   zHttpError._get_reason9   s<   %,TYY%A!!t	4zz$,,"5"5g">? $%gy1'+,|:d,|  A  (B$')-g7K)LD&D$'CIM"1g$W-i8G 44)4W)=i)HD&%)" >F' '' 4||**734 Hi0 		s0   .C*  BD *.DD DD D54D5c           	         | j                         }| j                  rEd| j                  j                  d| j                  d|j                         d| j                  d	S | j                  rFd| j                  j                  d| j                  d| j                         j                         dS d| j                  j                  d| j                         dS )Nz<HttpError z when requesting z returned "z". Details: ""> ")r   r   r   r   r   strip)r   r#   s     r   __repr__zHttpError.__repr__T   s    !!#		  ""	  XX		    "((*   -1II,<,<d>N>N>PQQr   N)r   r	   r
   r   util
positionalr   propertyr!   r   r@   __str__r   r   r   r   r   %   sH    .T__Q	 	    6R$ Gr   r   c                       e Zd ZdZy)InvalidJsonErrorz&The JSON returned could not be parsed.Nr   r   r   r   rG   rG   i   s    0r   rG   c                       e Zd ZdZy)UnknownFileTypez File type unknown or unexpected.Nr   r   r   r   rI   rI   o       *r   rI   c                       e Zd ZdZy)UnknownLinkTypez Link type unknown or unexpected.Nr   r   r   r   rL   rL   u   rJ   r   rL   c                       e Zd ZdZy)UnknownApiNameOrVersionz)No API with that name and version exists.Nr   r   r   r   rN   rN   {   s    3r   rN   c                       e Zd ZdZy)UnacceptableMimeTypeErrorz4That is an unacceptable mimetype for this operation.Nr   r   r   r   rP   rP      s    >r   rP   c                       e Zd ZdZy)MediaUploadSizeErrorz+Media is larger than the method can accept.Nr   r   r   r   rR   rR      s    5r   rR   c                       e Zd ZdZy)ResumableUploadErrorz'Error occurred during resumable upload.Nr   r   r   r   rT   rT      s    1r   rT   c                       e Zd ZdZy)InvalidChunkSizeErrorz!The given chunksize is not valid.Nr   r   r   r   rV   rV      s    +r   rV   c                       e Zd ZdZy)InvalidNotificationErrorz$The channel Notification is invalid.Nr   r   r   r   rX   rX      s    .r   rX   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 rA   )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   rB   rC   r   r@   rE   r   r   r   rZ   rZ      s/    1T__Q 
L Gr   rZ   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   rA   )r   r	   r
   r   rB   rC   r   __classcell__rf   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)rc   zExpected: [z] - Provided: []N)rd   rj   r   )r   expectedprovidedrf   s      r   r   zUnexpectedBodyError.__init__   s    !41198D	
r   )r   r	   r
   r   r   rg   rh   s   @r   rj   rj      s    F
 
r   rj   )r   
__future__r   r/   r   googleapiclientr   rB   	Exceptionr   r   rG   rI   rL   rN   rP   rR   rT   rV   rX   rZ   r`   rj   r   r   r   <module>rr      s    
 '  
 ,	I 	A AH	u 		e 		e 		e 		 		5 		9 		E 		u 	 $
E 

% 
r   