
    =Ki!                       S r SSKJr  SSKJr  SSKJr   " S S\5      r " S S\5      r " S	 S
\5      r	 " S S\5      r
 " S S\
5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      r " S# S$\5      r " S% S&\5      rg')(zCustom exceptions for the sandbox client.

All sandbox exceptions extend LangSmithError for unified error handling.
The exceptions are organized by error type rather than resource type,
with a resource_type attribute for specific handling when needed.
    )annotations)Optional)LangSmithErrorc                      \ rS rSrSrSrg)SandboxClientError   z)Base exception for sandbox client errors. N__name__
__module____qualname____firstlineno____doc____static_attributes__r	       _/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/langsmith/sandbox/_exceptions.pyr   r      s    3r   r   c                      \ rS rSrSrSrg)SandboxAPIError   znRaised when the API endpoint returns an unexpected error.

For example, this is raised for wrong URL or path.
r	   Nr
   r	   r   r   r   r          
 	r   r   c                      \ rS rSrSrSrg)SandboxAuthenticationError#   z>Raised when authentication fails (invalid or missing API key).r	   Nr
   r	   r   r   r   r   #   s    Hr   r   c                      \ rS rSrSrSrg)SandboxConnectionError)   z3Raised when connection to the sandbox server fails.r	   Nr
   r	   r   r   r   r   )   s    =r   r   c                      \ rS rSrSrSrg)SandboxServerReloadError/   u3  Raised when the server sends a 1001 Going Away close frame.

This indicates a server hot-reload, not a true connection failure.
The command is still running on the server.

This is a subclass of SandboxConnectionError, so the auto-reconnect
logic in CommandHandle catches it along with all other
connection errors. The distinction matters for retry strategy:
SandboxServerReloadError triggers immediate reconnect (no backoff),
while other SandboxConnectionError triggers exponential backoff.

Users typically never see this exception — it's handled internally.
r	   Nr
   r	   r   r   r   r   /   s     	r   r   c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )ResourceNotFoundErrorF   zRaised when a resource is not found.

Attributes:
    resource_type: Type of resource (sandbox, template, volume, pool, file).
c                0   > [         TU ]  U5        X l        gInitialize the error.Nsuper__init__resource_typeselfmessager)   	__class__s      r   r(   ResourceNotFoundError.__init__M       !*r   r)   Nr,   strr)   Optional[str]r   r   r   r   r   r(   r   __classcell__r-   s   @r   r!   r!   F       + +r   r!   c                  R   ^  \ rS rSrSr  S     SU 4S jjjrSU 4S jjrSrU =r$ )	ResourceTimeoutErrorS   zRaised when an operation times out.

Attributes:
    resource_type: Type of resource (sandbox, volume, pool).
    last_status: The last known status before timeout (for sandboxes).
c                <   > [         TU ]  U5        X l        X0l        gr$   )r'   r(   r)   last_status)r+   r,   r)   r=   r-   s       r   r(   ResourceTimeoutError.__init__[   s     	!*&r   c                j   > [         TU ]  5       nU R                  (       a  U SU R                   S3$ U$ )Return string representation.z (last_status: ))r'   __str__r=   )r+   baser-   s     r   rB   ResourceTimeoutError.__str__f   s7    w V?4+;+;*<A>>r   )r=   r)   NN)r,   r3   r)   r4   r=   r4   returnr3   	r   r   r   r   r   r(   rB   r   r6   r7   s   @r   r:   r:   S   s@     (,%)		'	' %	' #		' 	' r   r:   c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )ResourceInUseErrorn   z{Raised when deleting a resource that is still in use.

Attributes:
    resource_type: Type of resource (template, volume).
c                0   > [         TU ]  U5        X l        gr$   r&   r*   s      r   r(   ResourceInUseError.__init__u   r/   r   r0   r1   r2   r5   r7   s   @r   rJ   rJ   n   r8   r   rJ   c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )ResourceAlreadyExistsError{   ztRaised when creating a resource that already exists.

Attributes:
    resource_type: Type of resource (e.g., pool).
c                0   > [         TU ]  U5        X l        gr$   r&   r*   s      r   r(   #ResourceAlreadyExistsError.__init__   r/   r   r0   r1   r2   r5   r7   s   @r   rO   rO   {   r8   r   rO   c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )ResourceNameConflictError   zRaised when updating a resource name to one that already exists.

Attributes:
    resource_type: Type of resource (volume, template, pool, sandbox).
c                0   > [         TU ]  U5        X l        gr$   r&   r*   s      r   r(   "ResourceNameConflictError.__init__   r/   r   r0   r1   r2   r5   r7   s   @r   rT   rT      r8   r   rT   c                  H   ^  \ rS rSrSr   S       SU 4S jjjrSrU =r$ )ValidationError   a  Raised when request validation fails.

This includes:
- Resource values exceeding server-defined limits (CPU, memory, storage)
- Invalid resource units
- Invalid name formats
- Pool validation failures (e.g., template has volumes)

Attributes:
    field: The field that failed validation (e.g., "cpu", "memory").
    details: List of validation error details from the API.
    error_type: Machine-readable error type from the API.
c                \   > [         TU ]  U5        X l        U=(       d    / U l        X@l        gr$   )r'   r(   fielddetails
error_type)r+   r,   r\   r]   r^   r-   s        r   r(   ValidationError.__init__   s'     	!
}"$r   )r]   r^   r\   )NNN)r,   r3   r\   r4   r]   zOptional[list[dict]]r^   r4   r5   r7   s   @r   rY   rY      sC    "  $(,$(%% % &	%
 "% %r   rY   c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )QuotaExceededError   zRaised when organization quota limits are exceeded.

Users should contact support@langchain.dev to increase quotas.

Attributes:
    quota_type: Type of quota exceeded (e.g., "sandbox_count", "cpu").
c                0   > [         TU ]  U5        X l        gr$   )r'   r(   
quota_type)r+   r,   rd   r-   s      r   r(   QuotaExceededError.__init__       !$r   )rd   r1   )r,   r3   rd   r4   r5   r7   s   @r   ra   ra      s    % %r   ra   c                  D   ^  \ rS rSrSrSSU 4S jjjrSU 4S jjrSrU =r$ )	SandboxCreationError   zRaised when sandbox creation fails.

Attributes:
    error_type: Machine-readable error type (ImagePull, CrashLoop,
        SandboxConfig, Unschedulable).
c                0   > [         TU ]  U5        X l        gr$   )r'   r(   r^   )r+   r,   r^   r-   s      r   r(   SandboxCreationError.__init__   rf   r   c                ~   > U R                   (       a  [        TU ]	  5        SU R                    S3$ [        TU ]	  5       $ r@   z []r^   r'   rB   r+   r-   s    r   rB   SandboxCreationError.__str__   7    ??go'(4??*;1==w  r   )r^   r1   )r,   r3   r^   r4   rF   rH   r7   s   @r   rh   rh      s    % %
! !r   rh   c                      \ rS rSrSrSrg)DataplaneNotConfiguredError   zRaised when dataplane_url is not available for the sandbox.

This occurs when the sandbox-router URL is not configured for the cluster.
r	   Nr
   r	   r   r   rt   rt      r   r   rt   c                      \ rS rSrSrSrg)SandboxNotReadyError   zDRaised when attempting to interact with a sandbox that is not ready.r	   Nr
   r	   r   r   rw   rw      s    Nr   rw   c                  R   ^  \ rS rSrSr  S     SU 4S jjjrSU 4S jjrSrU =r$ )	SandboxOperationError   zRaised when a sandbox operation fails (run, read, write).

Attributes:
    operation: The operation that failed (command, read, write).
    error_type: Machine-readable error type from the API.
c                <   > [         TU ]  U5        X l        X0l        gr$   )r'   r(   	operationr^   )r+   r,   r}   r^   r-   s       r   r(   SandboxOperationError.__init__   s     	!"$r   c                ~   > U R                   (       a  [        TU ]	  5        SU R                    S3$ [        TU ]	  5       $ rm   ro   rp   s    r   rB   SandboxOperationError.__str__  rr   r   )r^   r}   rE   )r,   r3   r}   r4   r^   r4   rF   rH   r7   s   @r   rz   rz      s@     $($(		%	% !	% "		% 	%! !r   rz   c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )CommandTimeoutErrori  zuRaised when a command exceeds its timeout.

Attributes:
    timeout: The timeout value in seconds that was exceeded.
c                0   > [         TU ]  USSS9  X l        g)r%   commandCommandTimeout)r}   r^   N)r'   r(   timeout)r+   r,   r   r-   s      r   r(   CommandTimeoutError.__init__  s    IBRSr   )r   r1   )r,   r3   r   zOptional[int]r5   r7   s   @r   r   r     s     r   r   N)r   
__future__r   typingr   langsmith.utilsr   r   r   r   r   r   r!   r:   rJ   rO   rT   rY   ra   rh   rt   rw   rz   r   r	   r   r   <module>r      s    #  *	 		( 		!3 		/ 		5 	.
+. 
+- 6
++ 
+
+!3 
+
+ 2 
+$%( %:%+ %(!- !2	"4 		- 	!. !4
/ 
r   