
    YjE                       d Z ddlm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	 	 d'd(d&ZdS ))z(Exception classes for Honcho SDK errors.    )annotations)Anyc                  `     e Zd ZU dZded<   ded<   ded<   ded	<   d
dddd fdZddZ xZS )HonchoErrorz+Base error class for all Honcho SDK errors.strmessageintstatus
str | Nonecoder   bodyr   Nr
   r   r   returnNonec                   t                                          |           || _        || _        || _        || _        d S )N)super__init__r   r
   r   r   )selfr   r
   r   r   	__class__s        ]/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/honcho/http/exceptions.pyr   zHonchoError.__init__   s=     	!!!				    c                @    | j         j         d| j        d| j         dS )Nz	(message=z	, status=))r   __name__r   r
   )r   s    r   __repr__zHonchoError.__repr__   s,    ~&XXXX$+XXX	
r   )
r   r   r
   r	   r   r   r   r   r   r   )r   r   )r   
__module____qualname____doc____annotations__r   r   __classcell__r   s   @r   r   r      s         55LLLKKKIII        
 
 
 
 
 
 
 
r   r   c                  *     e Zd ZdZddd fdZ xZS )APIErrorz1Error from an API response with HTTP status code.Nr   r   r   r
   r	   r   r   r   r   c               R    t                                          ||d|           d S )N	api_errorr   r   r   )r   r   r
   r   r   s       r   r   zAPIError.__init__'   s,     	kMMMMMr   )r   r   r
   r	   r   r   r   r   r   r   r   r   r   r    r!   s   @r   r#   r#   $   s^        ;; N N N N N N N N N N N Nr   r#   c                  &     e Zd ZdZdd fd
Z xZS )BadRequestErrorz1Error thrown when request validation fails (400).Bad requestNr   r   r   r   r   r   c                ^    t                                          |d|           d| _        d S )N  r
   r   bad_requestr   r   r   r   r   r   r   s      r   r   zBadRequestError.__init__4   s-    4888!			r   )r+   Nr   r   r   r   r   r   r(   r!   s   @r   r*   r*   1   sH        ;;" " " " " " " " " " "r   r*   c                  &     e Zd ZdZdd	 fdZ xZS )
AuthenticationErrorz-Error thrown when authentication fails (401).Authentication failedr   r   r   r   c                \    t                                          |d           d| _        d S )N  r
   authentication_errorr0   r   r   r   s     r   r   zAuthenticationError.__init__<   s+    ---*			r   )r5   r   r   r   r   r(   r!   s   @r   r4   r4   9   sH        77+ + + + + + + + + + +r   r4   c                  &     e Zd ZdZdd	 fdZ xZS )
PermissionDeniedErrorz2Error thrown when the user lacks permission (403).Permission deniedr   r   r   r   c                \    t                                          |d           d| _        d S )N  r8   permission_deniedr0   r:   s     r   r   zPermissionDeniedError.__init__D   s+    ---'			r   )r>   r;   r(   r!   s   @r   r=   r=   A   sH        <<( ( ( ( ( ( ( ( ( ( (r   r=   c                  &     e Zd ZdZdd	 fdZ xZS )
NotFoundErrorz0Error thrown when a resource is not found (404).Resource not foundr   r   r   r   c                \    t                                          |d           d| _        d S )N  r8   	not_foundr0   r:   s     r   r   zNotFoundError.__init__L   s+    ---			r   )rD   r;   r(   r!   s   @r   rC   rC   I   sH        ::                     r   rC   c                  &     e Zd ZdZdd fd
Z xZS )ConflictErrorz(Error thrown on resource conflict (409).Resource conflictNr   r   r   r   r   r   c                ^    t                                          |d|           d| _        d S )N  r.   conflictr0   r1   s      r   r   zConflictError.__init__T   s-    4888			r   )rJ   Nr2   r(   r!   s   @r   rI   rI   Q   sH        22          r   rI   c                  &     e Zd ZdZdd fd
Z xZS )UnprocessableEntityErrorz3Error thrown when entity cannot be processed (422).Unprocessable entityNr   r   r   r   r   r   c                ^    t                                          |d|           d| _        d S )N  r.   unprocessable_entityr0   r1   s      r   r   z!UnprocessableEntityError.__init__\   s-    4888*			r   )rP   Nr2   r(   r!   s   @r   rO   rO   Y   sH        ==+ + + + + + + + + + +r   rO   c                  :     e Zd ZU dZdZded<   	 	 dd fd
Z xZS )RateLimitErrorz%Error thrown when rate limited (429).Nfloat | Noneretry_afterRate limit exceededr   r   r   r   c                j    t                                          |d           d| _        || _        d S )N  r8   rate_limit_exceeded)r   r   r   rW   )r   r   rW   r   s      r   r   zRateLimitError.__init__f   s7    
 	---)	&r   )rX   N)r   r   rW   rV   r   r   )r   r   r   r   rW   r   r   r    r!   s   @r   rU   rU   a   sc         // $K$$$$ -$(' ' ' ' ' ' ' ' ' ' 'r   rU   c                  &     e Zd ZdZdd fd
Z xZS )ServerErrorz$Error thrown on server errors (5xx).Server error  r   r   r
   r	   r   r   c                \    t                                          ||           d| _        d S )Nr8   server_errorr0   )r   r   r
   r   s      r   r   zServerError.__init__s   s+    000"			r   )r^   r_   )r   r   r
   r	   r   r   r(   r!   s   @r   r]   r]   p   sH        ..# # # # # # # # # # #r   r]   c                  &     e Zd ZdZdd	 fdZ xZS )
TimeoutErrorz&Error thrown when a request times out.Request timed outr   r   r   r   c                N    t                                          |d           d S )Ntimeoutr   r'   r:   s     r   r   zTimeoutError.__init__{   s&    y11111r   )rd   r;   r(   r!   s   @r   rc   rc   x   sH        002 2 2 2 2 2 2 2 2 2 2r   rc   c                  &     e Zd ZdZdd	 fdZ xZS )
ConnectionErrorz%Error thrown when a connection fails.Connection failedr   r   r   r   c                N    t                                          |d           d S )Nconnection_errorrg   r'   r:   s     r   r   zConnectionError.__init__   s'    '9:::::r   )rj   r;   r(   r!   s   @r   ri   ri      sH        //; ; ; ; ; ; ; ; ; ; ;r   ri   Nr
   r	   r   r   r   r   rW   rV   r   c                   | dk    rt          ||          S | dk    rt          |          S | dk    rt          |          S | dk    rt          |          S | dk    rt	          ||          S | dk    rt          ||          S | dk    rt          ||	          S | d
k    rt          ||           S t          || |          S )z<Create the appropriate error type based on HTTP status code.r-   r$   r7   r@   rF   rL   rR   rZ   )rW   r_   r8   r.   )	r*   r4   r=   rC   rI   rO   rU   r]   r#   )r
   r   r   rW   s       r   create_error_from_responsern      s     }}wT2222	3"7+++	3$W---	3W%%%	3W40000	3'd;;;;	3g;????	3762222T::::r   )NN)
r
   r	   r   r   r   r   rW   rV   r   r   )r   
__future__r   typingr   	Exceptionr   r#   r*   r4   r=   rC   rI   rO   rU   r]   rc   ri   rn    r   r   <module>rs      sZ   . . " " " " " "      
 
 
 
 
) 
 
 
8
N 
N 
N 
N 
N{ 
N 
N 
N" " " " "h " " "+ + + + +( + + +( ( ( ( (H ( ( (         H          H   + + + + +x + + +' ' ' ' 'X ' ' '# # # # #( # # #2 2 2 2 2; 2 2 2; ; ; ; ;k ; ; ;  $	; ; ; ; ; ; ;r   