
    h                     8   d dl mZmZmZm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y)    )DictOptionalUnioncastNErrorObjectc                   8    e Zd ZU ee   ed<   ee   ed<   ee   ed<   ee   ed<   eeeef      ed<   ee   ed<   ee   ed<   ed   ed	<   	 	 	 	 	 	 dd
ee   dee	e
ef      dee   dee   deeeef      dee   f fdZd Zed        Zd Zdee   fdZ xZS )StripeError_message	http_bodyhttp_status	json_bodyheaderscode
request_idr   errormessagec                    t         t        |   |       d }|r?t        |d      r!	 t	        t
        |      j                  d      }nt        |t              r|}|| _
        || _        || _        || _        |xs i | _        || _        | j                  j!                  dd       | _        | j%                         | _        y # t        $ r d}Y rw xY w)Ndecodezutf-8zE<Could not decode body as utf-8. Please report to support@stripe.com>z
request-id)superr
   __init__hasattrr   bytesr   BaseException
isinstancestrr   r   r   r   r   r   getr   _construct_error_objectr   )	selfr   r   r   r   r   r   body	__class__s	           M/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/stripe/_error.pyr   zStripeError.__init__   s     	k4)'2" y(+y188AD Is+ &"}"	,,**<>113
 % ? s   B= =C
Cc                 v    | j                   xs d}| j                  dj                  | j                  |      S |S )Nz<empty message>zRequest {0}: {1})r   r   format)r   msgs     r"   __str__zStripeError.__str__5   s7    mm00??&%,,T__cBBJ    c                     | j                   S N)r   r   s    r"   user_messagezStripeError.user_message@   s    }}r'   c                     | j                   j                  d| j                  d| j                  d| j                  dS )N	(message=, http_status=, request_id=))r!   __name__r   r   r   r*   s    r"   __repr__zStripeError.__repr__D   s0    NN##MMOO	
 	
r'   returnc                 .   | j                   Et        | j                   t              r+d| j                   vst        | j                   d   t              sy ddlm}  |j
                  | j                   d   t        j                  j                         d      S )Nr   r   r   V1)values	requestorapi_mode)	r   r   dictstripe._error_objectr   _construct_fromstripe_APIRequestor_global_instance)r   r   s     r"   r   z#StripeError._construct_error_objectL   sw    NN"dnnd3dnn,dnnW5t<4*{**>>'***;;= 
 	
r'   )NNNNNN)r1   
__module____qualname__r   r   __annotations__intobjectr   r   r   r   r&   propertyr+   r2   r   r   __classcell__r!   s   @r"   r
   r
      s   sm}#d38n%%
3-M"" "&15%)&*,0""4#"4 E%*-."4 c]	"4
 F#"4 $sCx.)"4 sm"4H  

+)> 
r'   r
   c                       e Zd Zy)APIErrorNr1   r?   r@    r'   r"   rH   rH   _       r'   rH   c                   8     e Zd ZU eed<   	 	 	 	 	 	 d fd	Z xZS )APIConnectionErrorshould_retryc                 D    t         t        |   ||||||       || _        y r)   )r   rM   r   rN   )	r   r   r   r   r   r   r   rN   r!   s	           r"   r   zAPIConnectionError.__init__f   s,     	 $0YY	
 )r'   )NNNNNF)r1   r?   r@   boolrA   r   rE   rF   s   @r"   rM   rM   c   s'    
 ) )r'   rM   c                       e Zd Zd Zy)StripeErrorWithParamCodec                     | j                   j                  d| j                  d| j                  d| j                  d| j
                  d| j                  dS )Nr-   z, param=z, code=r.   r/   r0   )r!   r1   r   paramr   r   r   r*   s    r"   r2   z!StripeErrorWithParamCode.__repr__w   s@    
 ''

		  		
r'   N)r1   r?   r@   r2   rJ   r'   r"   rR   rR   v   s    
r'   rR   c                   (     e Zd Z	 	 	 	 d fd	Z xZS )	CardErrorc                 D    t         t        |   ||||||       || _        y r)   )r   rV   r   rT   	r   r   rT   r   r   r   r   r   r!   s	           r"   r   zCardError.__init__   s*     	i'YY	
 
r'   )NNNNr1   r?   r@   r   rE   rF   s   @r"   rV   rV      s      r'   rV   c                       e Zd Zy)IdempotencyErrorNrI   rJ   r'   r"   r[   r[      rK   r'   r[   c                   *     e Zd Z	 	 	 	 	 d fd	Z xZS )InvalidRequestErrorc                 D    t         t        |   ||||||       || _        y r)   )r   r]   r   rT   rX   s	           r"   r   zInvalidRequestError.__init__   s+     	!41YY	
 
r'   )NNNNNrY   rF   s   @r"   r]   r]      s    
  r'   r]   c                       e Zd Zy)AuthenticationErrorNrI   rJ   r'   r"   r`   r`      rK   r'   r`   c                       e Zd Zy)PermissionErrorNrI   rJ   r'   r"   rb   rb      rK   r'   rb   c                       e Zd Zy)RateLimitErrorNrI   rJ   r'   r"   rd   rd      rK   r'   rd   c                         e Zd Zd fd	Z xZS )SignatureVerificationErrorc                 <    t         t        |   ||       || _        y r)   )r   rf   r   
sig_header)r   r   rh   r   r!   s       r"   r   z#SignatureVerificationError.__init__   s    ($8)L$r'   r)   rY   rF   s   @r"   rf   rf      s    % %r'   rf   c                       e Zd Zy)TemporarySessionExpiredErrorNrI   rJ   r'   r"   rj   rj      rK   r'   rj   )typingr   r   r   r   r<   r:   r   	Exceptionr
   rH   rM   rR   rV   r[   r]   r`   rb   rd   rf   rj   rJ   r'   r"   <module>rm      s    . .  ,U
) U
p	{ 	) )&
{ 
 ( "	{ 	2 "	+ 		k 		[ 	% %	; 	r'   