o
    î6Wj¤  ã                   @  s”  d dl mZ d dlmZmZ d dlmZ d dlZddlm	Z	 ddl
mZ g d¢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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/d0„ d0eƒZ!dS )1é    )Úannotations)ÚUnionÚcast)ÚLiteralNé   )Úis_dict)Ú	ErrorType)ÚBadRequestErrorÚAuthenticationErrorÚPermissionDeniedErrorÚNotFoundErrorÚConflictErrorÚUnprocessableEntityErrorÚRateLimitErrorÚInternalServerErrorc                   @  ó   e Zd ZdS )ÚAnthropicErrorN©Ú__name__Ú
__module__Ú__qualname__© r   r   úd/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/anthropic/_exceptions.pyr      ó    r   c                      s:   e Zd ZU ded< ded< ded< 	 d‡ fd	d
„Z‡  ZS )ÚAPIErrorÚstrÚmessageúhttpx.RequestÚrequestúobject | NoneÚbodyÚreturnÚNonec                  s"   t ƒ  |¡ || _|| _|| _d S )N)ÚsuperÚ__init__r   r   r    )Úselfr   r   r    ©Ú	__class__r   r   r$   ,   s   
zAPIError.__init__)r   r   r   r   r    r   r!   r"   ©r   r   r   Ú__annotations__r$   Ú__classcell__r   r   r&   r   r      s   
 
r   c                      s6   e Zd ZU ded< ded< ddœd‡ fdd„Z‡  ZS )ÚAPIResponseValidationErrorúhttpx.ResponseÚresponseÚintÚstatus_codeN©r   r    r   r   ú
str | Noner!   r"   c                  s*   t ƒ j|pd|j|d� || _|j| _d S )Nz1Data returned by API invalid for expected schema.©r    )r#   r$   r   r-   r/   )r%   r-   r    r   r&   r   r   r$   7   s   z#APIResponseValidationError.__init__)r-   r,   r    r   r   r1   r!   r"   r(   r   r   r&   r   r+   3   s   
 r+   c                   @  r   )ÚAPIWebhookValidationErrorNr   r   r   r   r   r3   =   r   r3   c                      sD   e Zd ZU dZded< ded< ded< ded	< d‡ fdd„Z‡  ZS )ÚAPIStatusErrorz<Raised when an API response has a status code of 4xx or 5xx.r,   r-   r.   r/   r1   Ú
request_idzErrorType | NoneÚtyper   r   r    r   r!   r"   c                  sv   t ƒ j||j|d� || _|j| _|j d¡| _d | _t	|ƒr7| d¡}t	|ƒr9t
ttd f | d¡ƒ| _d S d S d S )Nr2   z
request-idÚerrorr6   )r#   r$   r   r-   r/   ÚheadersÚgetr5   r6   r   r   r   r   )r%   r   r-   r    r7   r&   r   r   r$   I   s   
ýzAPIStatusError.__init__)r   r   r-   r,   r    r   r!   r"   )r   r   r   Ú__doc__r)   r$   r*   r   r   r&   r   r4   A   s   
 r4   c                      s$   e Zd Zddœd‡ fd	d
„Z‡  ZS )ÚAPIConnectionErrorzConnection error.r0   r   r   r   r   r!   r"   c                  s   t ƒ j||d d� d S )Nr2   ©r#   r$   )r%   r   r   r&   r   r   r$   W   s   zAPIConnectionError.__init__)r   r   r   r   r!   r"   ©r   r   r   r$   r*   r   r   r&   r   r;   V   s    r;   c                      s   e Zd Zd‡ fdd„Z‡  ZS )ÚAPITimeoutErrorr   r   r!   r"   c                   s   t ƒ jd|d� d S )NzÃRequest timed out or interrupted. This could be due to a network timeout, dropped connection, or request cancellation. See https://docs.anthropic.com/en/api/errors#long-requests for more details.)r   r   r<   )r%   r   r&   r   r   r$   \   s   
þzAPITimeoutError.__init__)r   r   r!   r"   r=   r   r   r&   r   r>   [   s    r>   c                   @  s   e Zd ZdZdS )ÚRetryableErrora  An error that opts into the SDK's retry policy: raise it (e.g. from
    middleware) to have the request attempt retried.

    The request is only retried while `max_retries` has not been exhausted;
    once exhausted the error propagates to the caller as-is.
    N)r   r   r   r:   r   r   r   r   r?   c   s    r?   c                   @  ó   e Zd ZU dZded< dS )r	   i�  zLiteral[400]r/   N©r   r   r   r/   r)   r   r   r   r   r	   l   ó   
 r	   c                   @  r@   )r
   i‘  zLiteral[401]r/   NrA   r   r   r   r   r
   p   rB   r
   c                   @  r@   )r   i“  zLiteral[403]r/   NrA   r   r   r   r   r   t   rB   r   c                   @  r@   )r   i”  zLiteral[404]r/   NrA   r   r   r   r   r   x   rB   r   c                   @  r@   )r   i™  zLiteral[409]r/   NrA   r   r   r   r   r   |   rB   r   c                   @  r@   )ÚRequestTooLargeErrori�  zLiteral[413]r/   NrA   r   r   r   r   rC   €   rB   rC   c                   @  r@   )r   i¦  zLiteral[422]r/   NrA   r   r   r   r   r   „   rB   r   c                   @  r@   )r   i­  zLiteral[429]r/   NrA   r   r   r   r   r   ˆ   rB   r   c                   @  r@   )ÚServiceUnavailableErrori÷  zLiteral[503]r/   NrA   r   r   r   r   rD   Œ   rB   rD   c                   @  r@   )ÚOverloadedErrori  zLiteral[529]r/   NrA   r   r   r   r   rE   �   rB   rE   c                   @  r@   )ÚDeadlineExceededErroriø  zLiteral[504]r/   NrA   r   r   r   r   rF   ”   rB   rF   c                   @  r   )r   Nr   r   r   r   r   r   ˜   r   r   )"Ú
__future__r   Útypingr   r   Útyping_extensionsr   ÚhttpxÚ_utilsr   Útypes.shared.error_typer   Ú__all__Ú	Exceptionr   r   r+   r3   r4   r;   r>   r?   r	   r
   r   r   r   rC   r   r   rD   rE   rF   r   r   r   r   r   Ú<module>   s6   
	