o
    沪gK                     @  s   U d dl mZ d dlmZ d dlZd dlm  mZ d dlmZ d dl	m
Z
 d dlmZ eeZded< dddZdddZdddZdS )    )annotations)FinalN)config)get_dg_singleton_instance)
get_loggerr   _LOGGEReBaseExceptionreturnNonec                   s   ddl m m} G  fddd|j}ddl m} ||_ddlm} |ddd	d
dd}||jj	t
| | | jd	d
dd
dtgd	 d S )Nr   )boxpanelc                      s&   e Zd Zdf fdd	Z  ZS )z0_print_rich_exception.<locals>.ConfigurablePaneluP   ────
    
────
    
────
────
    
────
c                   s   t  j||fi | d S )N)super__init__)self
renderabler   kwargs	__class__ P/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/streamlit/error_util.pyr   !   s   z9_print_rich_exception.<locals>.ConfigurablePanel.__init__)__name__
__module____qualname__Boxr   __classcell__r   r   r   r   ConfigurablePanel    s    r   )	traceback)Console256TX   F   )color_systemforce_terminalwidthno_colortab_sized      )r%   show_locals
max_frames	word_wrapextra_linessuppress)richr   r   Panelr   rich.consoler   print	Tracebackfrom_exceptiontype__traceback__	streamlit)r   r   r   rich_tracebackr   consoler   r   r   _print_rich_exception   s2   		r:   exc                 C  s   t  j}tj|| dd dS )z#Show the exception on the frontend.T)is_uncaught_app_exceptionN)r   main_dg	exception
_exception)r;   main_delta_generatorr   r   r   _show_exceptionH   s   rA   c                 C  sT   d}t drzt|  d}W n ty   d}Y nw |s$tjd| d t|  dS )zHandle an exception that originated from a user app.

    By default, we show exceptions directly in the browser. However,
    if the user has disabled client error details, we display a generic
    warning in the frontend instead.
    Fzlogger.enableRichTzUncaught app execution)exc_infoN)r   
get_optionr:   	Exceptionr   errorrA   )r;   error_loggedr   r   r   handle_uncaught_app_exceptionN   s   
rG   )r   r	   r
   r   )r;   r	   r
   r   )
__future__r   typingr   r7   streamlit.elements.exceptionelementsr>   r   $streamlit.delta_generator_singletonsr   streamlit.loggerr   r   r   __annotations__r:   rA   rG   r   r   r   r   <module>   s   

,