o
    ۷i                     @  s  d dl mZ d dlmZ d dlm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eZedd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d"S )#    )annotations)document)AppErrorc                   @     e Zd ZdZdS )DuplicateBlockErrorzBRaised when a Blocks contains more than one Block with the same idN__name__
__module____qualname____doc__ r   r   G/home/ubuntu/vllm_env/lib/python3.10/site-packages/gradio/exceptions.pyr          r   c                   @  r   )InvalidComponentErrorz(Raised when invalid components are used.Nr   r   r   r   r   r      r   r   c                   @  r   )ModelNotFoundErrorzVRaised when the provided model doesn't exists or is not found by the provided api url.Nr   r   r   r   r   r      r   r   c                   @  r   )RenderErrorzjRaised when a component has not been rendered in the current Blocks but is expected to have been rendered.Nr   r   r   r   r   r      r   r   c                   @     e Zd ZdS )InvalidApiNameErrorNr   r	   r
   r   r   r   r   r          r   c                   @  r   )ServerFailedToStartErrorNr   r   r   r   r   r   #   r   r   c                   @  r   )InvalidBlockErrorzcRaised when an event in a Blocks contains a reference to a Block that is not in the original BlocksNr   r   r   r   r   r   '   r   r   c                   @  r   )ReloadErrorz?Raised when something goes wrong when reloading the gradio app.Nr   r   r   r   r   r   -   r   r   c                   @  r   )GradioVersionIncompatibleErrorz(Raised when loading a 3.x space with 4.0Nr   r   r   r   r   r   3   r   r   modals)documentation_groupc                      s6   e Zd ZdZ				 	dd fddZdd Z  ZS )Errora  
    This class allows you to pass custom error messages to the user. You can do so by raising a gr.Error("custom message") anywhere in the code, and when that line is executed the custom message will appear in a modal on the demo.
    Example:
        import gradio as gr
        def divide(numerator, denominator):
            if denominator == 0:
                raise gr.Error("Cannot divide by zero!")
        gr.Interface(divide, ["number", "number"], "number").launch()
    Demos: calculator, blocks_chained_events
    Error raised.
   Tmessagestrdurationfloat | Nonevisiblebooltitleprint_exceptionc                   s   t  j|||||d dS )a?  
        Parameters:
            message: The error message to be displayed to the user. Can be HTML, which will be rendered in the modal.
            duration: The duration in seconds to display the error message. If None or 0, the error message will be displayed until the user closes it.
            visible: Whether the error message should be displayed in the UI.
            title: The title to be displayed to the user at the top of the error modal.
            print_exception: Whether to print traceback of the error to the console when the error is raised.
        )r   r!   r#   r%   r&   Nsuper__init__)selfr   r!   r#   r%   r&   	__class__r   r   r)   I   s   
zError.__init__c                 C  s
   t | jS N)reprr   )r*   r   r   r   __str__a   s   
zError.__str__)r   r   Tr   T)
r   r    r!   r"   r#   r$   r%   r    r&   r$   )r   r	   r
   r   r)   r/   __classcell__r   r   r+   r   r   <   s    r   c                   @  r   )ComponentDefinitionErrorNr   r   r   r   r   r1   e   r   r1   c                   @  r   )InvalidPathErrorNr   r   r   r   r   r2   i   r   r2   c                   @  r   )ChecksumMismatchErrorNr   r   r   r   r   r3   m   r   r3   c                      s$   e Zd ZdZdd fddZ  ZS )	TooManyRequestsErrorz;Raised when the Hugging Face API returns a 429 status code.*Too many requests. Please try again later.r   r    c                   s   t  | d S r-   r'   )r*   r   r+   r   r   r)   t   s   zTooManyRequestsError.__init__)r5   )r   r    )r   r	   r
   r   r)   r0   r   r   r+   r   r4   q   s    r4   N)
__future__r   gradio_client.documentationr   gradio_client.exceptionsr   
ValueErrorr   r   	Exceptionr   r   r   r   r   r   r   InvalidApiNamer   NotImplementedErrorr1   r2   r3   r4   r   r   r   r   <module>   s&    (