o
    Yh                     @  s   U d dl mZ d dlmZmZ d dlZd dl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)AnyFinalN)config)get_dg_singleton_instance)	exception)
get_loggerr   _LOGGEReBaseExceptionreturnNonec                   s   ddl m  ddlm} G  fddd|}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d fd	d
Z  ZS )z0_print_rich_exception.<locals>.ConfigurablePanelN
renderabler   box
Box | Nonekwargsr   r   c                   s*   t  j||d ur
|n dfi | d S )NuP   ────
    
────
    
────
────
    
────
)super__init__)selfr   r   r   )r   	__class__ U/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/streamlit/error_util.pyr   "   s   
z9_print_rich_exception.<locals>.ConfigurablePanel.__init__)N)r   r   r   r   r   r   r   r   )__name__
__module____qualname__r   __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)rich.boxr   
rich.panelr   richr    rich.consoler!   print	Tracebackfrom_exceptiontype__traceback__	streamlit)r
   r   r   rich_tracebackr!   consoler   r   r   _print_rich_exception   s4   	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_dgr   
_exception)r>   main_delta_generatorr   r   r   _show_exceptionO   s   rC   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	   errorrC   )r>   error_loggedr   r   r   handle_uncaught_app_exceptionU   s   
rI   )r
   r   r   r   )r>   r   r   r   )
__future__r   typingr   r   r:   r   $streamlit.delta_generator_singletonsr   streamlit.elementsr   streamlit.loggerr   r   r	   __annotations__r=   rC   rI   r   r   r   r   <module>   s   

3